@Test(timeout = 2000) public void testWaitForConsume() throws InterruptedException { long start = System.currentTimeMillis(); new Thread() { @Override @SneakyThrows public void run() { sleep(500); addTraces(2); } }.start(); queue.consume(); long total = System.currentTimeMillis() - start; Assert.assertTrue(total>=500); }
public List<Span> consume() throws InterruptedException { List<Span> rc; synchronized (this) { while (spans == null) { wait(); } rc = spans; spans = null; } return rc; }
TraceQueue { public List<Span> consume() throws InterruptedException { List<Span> rc; synchronized (this) { while (spans == null) { wait(); } rc = spans; spans = null; } return rc; } }
TraceQueue { public List<Span> consume() throws InterruptedException { List<Span> rc; synchronized (this) { while (spans == null) { wait(); } rc = spans; spans = null; } return rc; }  }
TraceQueue { public List<Span> consume() throws InterruptedException { List<Span> rc; synchronized (this) { while (spans == null) { wait(); } rc = spans; spans = null; } return rc; }  void supply(Span span); List<Span> consume(); }
TraceQueue { public List<Span> consume() throws InterruptedException { List<Span> rc; synchronized (this) { while (spans == null) { wait(); } rc = spans; spans = null; } return rc; }  void supply(Span span); List<Span> consume();  }