Divers
Divers

Reputation: 9569

Is it possible to add or modify element at the head of linked blocking queue?

Or maybe will be better to use other class for synchronized access to data?

Upvotes: 5

Views: 6107

Answers (3)

jlemos
jlemos

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

Perception
Perception

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

artbristol
artbristol

Reputation: 32437

Use LinkedBlockingDeque if you want to manipulate both ends of a queue.

Upvotes: 12

Related Questions