This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes acquireInterruptibly => InterruptedException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "acquireInterruptibly => InterruptedException" Watch "acquireInterruptibly => InterruptedException" New topic

acquireInterruptibly => InterruptedException

Jean-Michel Vilain

Joined: Aug 06, 2010
Posts: 27

This exception:
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(
at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(
at java.util.concurrent.ArrayBlockingQueue.put(

My beautifully simple Scheduler's code:

Why? Happens very rarely... Where should I be looking for the cause?

Designer and developer on Faëria: Strategy Card Game ( The server is 100% Java.
@Jiem_ on Twitter (
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

The thread which called the schedule method gets interrupted. We don't have any information about where schedule gets called, or what might be happening in and to that thread, so it is impossible for us to say. If you aren't sure of the sequence then start peppering your code with tons of log statements so you can see exactly the flow and what happens at or around the thread being interrupted.

edit: And remember: the interrupt doesn't have to happen while the put() operation is in progress, it just has to happen some time before the operation and not be cleared (using the Thread#interrupted() method, for example).

Jean-Michel Vilain

Joined: Aug 06, 2010
Posts: 27

Thanks a lot for your clarifications Steve.
In my mind the put is almost instant so I found it very unlikely to have the thread interrupted right at this moment.
Helps a lot!!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: acquireInterruptibly => InterruptedException
It's not a secret anymore!