Reputation: 9569
Or maybe will be better to use other class for synchronized access to data?
Upvotes: 5
Views: 6107
Reputation: 536
Not sure if I understood your question correctly, but LinkedBlockingDeque provides both FIFO and LIFO operations (similar to a Stack). Maybe it does what you want.
Upvotes: 3
Reputation: 80633
You can modify the element at the head of a linked blocking queue (use peek()
to obtain it. If you want to add elements to the head of a data structure then use a LinkedBlockingDeque instead.
Upvotes: 4
Reputation: 32437
Use LinkedBlockingDeque
if you want to manipulate both ends of a queue.
Upvotes: 12