Is there a synchronized queue in Java?

Does Java have a Queue class synchronized? I am looking for something like Vector (which is synchronized) vs ArrayList (it is not), but instead of implementing the List interface, I am looking for it to implement Queue .

Note that there is no Collections.synchronizedQueue method for migrating an unsynchronized queue and synchronizing it.

+9
source share
3 answers

Take a look at ArrayBlockingQueue and another BlockingQueue .

From the documentation:

A queue that additionally supports operations that wait for the queue to become empty when the item is retrieved, and wait until space becomes available in the queue when the item is stored.

+9
source

You can use "BlockingQueue", the link below can help you get a better idea.

BlockingQueue , queue implementations

+3
source

All Articles