I have something like this in my code:
worker.setObject(queue.poll());
I want a queue that when the poll method (or another one) is called, if the queue is empty, it wait until there is an object to return (not return null). There is some queue or method that does this.
You want to look for a class that implements
java.util.concurrent.BlockingQueue. Those classes do what you want 🙂