Search code examples
javaconcurrencylockingreentrantlock

Actual use of lockInterruptibly for a ReentrantLock


What do you actually use for this method lockInterruptibly? I have read the API however it's not very clear to me. Could anybody express it in other words?


Solution

  • The logic is the same as for all interruptible blocking methods: it allows the thread to immediately react to the interrupt signal sent to it from another thread.

    How this particular feature is used is up to the application design. For example, it can be used to kill a contingent of threads in a pool which are all waiting to aquire a lock.