Actual use of lockInterruptibly for a ReentrantLock
What do you actually use for this method ? I have read the API however it's not very clear to me. Could anybody express it in other words?lockInterruptibly
What do you actually use for this method ? I have read the API however it's not very clear to me. Could anybody express it in other words?lockInterruptibly
lockInterruptibly()
may block if the the lock is already held by another thread and will wait until the lock is aquired. This is the same as with regular . But if another thread interrupts the waiting thread will throw .lock()
lockInterruptibly()
InterruptedException
The logic is the same as for all interruptible blocking methods: it allows the thread to immediately react to the signal sent to it from another thread.interrupt
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.