From the course: Java SE 11 Developer (1Z0-819) Cert Prep

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Concurrent queues and collections

Concurrent queues and collections - Java Tutorial

From the course: Java SE 11 Developer (1Z0-819) Cert Prep

Concurrent queues and collections

- Now let's dive into concurrent queues and collections. The concurrent APIs provide a specialization, a subclass, if you like, of the Queue interface, which is the BlockingQueue. The structure will be thread-safe, and inserting an item happens before removal of that item, potentially in another thread. If the queue is full, the put method will block until space is available. And if the queue is empty, the take method will block until new data is available. Also, the order of insertion to removal is maintained. There will be no duplications or data loss, even the face of multiple inserting and removing threads concurrently. So, put one item in, you'll get that one item out once, no matter how many conflicts there are for putting things in or for taking things out. So, here's the API documentation page for the BlockingQueue. Obviously, it's generic so you can decide what types go into it. It is in itself a Collection Iterable and a specialization also of Queue. There is a BlockingDeque…

Contents