Java provides a blocking queue in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa, via SynchronousQueue:
BlockingQueue<String> queue = new SynchronousQueue<>();
Java provides a blocking queue in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa, via SynchronousQueue:
BlockingQueue<String> queue = new SynchronousQueue<>();