This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
"Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available."
The verbiage "if it is possible to do so immediately" seems to indicate that it can NOT block but I have a Thread that is calling this method that either dies or blocks indefinitely. The run loop is inside a try/catch block so the thread should not die. I am wondering if the thread might be seizing up on the call to offerFirst.
Ireneusz Kordal wrote:
It seems that offerFirst blocks.
When the JavaDoc implies that it doesn't block, it is saying that there is no situation that can cause it to block indefinitely -- which is generally caused by a call to the condition variable await() method, because the queue is full.
The locks are just held long enough to do the task, and maintain thread safety.