Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There is a queue in Java that wait for an object when poll is called?

Tags:

java

queue

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.

like image 719
Renato Dinhani Avatar asked Mar 14 '26 04:03

Renato Dinhani


1 Answers

Yes, this one, for example.

like image 68
Jakub Zaverka Avatar answered Mar 16 '26 17:03

Jakub Zaverka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!