@Test
public void testMultipleThreads() throws InterruptedException {

    final SpanSink sink = mock(SpanSink.class);
    SpanSinkRegistry.register(sink);
    final CyclicBarrier inside = new CyclicBarrier(2);
    final Thread one = new Thread(new BarrierSpanRunner("threadOne", inside));
    final Thread two = new Thread(new BarrierSpanRunner("threadTwo", inside));
    one.start();
    two.start();
    one.join();
    two.join();
    final ArgumentCaptor<Span> captor = ArgumentCaptor.forClass(Span.class);
    verify(sink, times(2)).record(captor.capture());
    final List<Span> spans = captor.getAllValues();
    assertEquals(2, spans.size());
    assertEquals(Optional.<BigInteger>absent(), spans.get(0).getParentSpanId());
    assertEquals(Optional.<BigInteger>absent(), spans.get(1).getParentSpanId());
}