Java Reference
In-Depth Information
Listing 13.4. Locking with a Time Budget.
The canonical structure of interruptible lock acquisition is slightly more complicated than
normal lock acquisition, as two try blocks are needed. (If the interruptible lock acquisition
can throw InterruptedException , the standard try-finally locking idiom
works.) Listing 13.5 uses lockInterruptibly to implement sendOnSharedLine
from Listing 13.4 so that we can call it from a cancellable task. The timed tryLock is also
responsive to interruption and so can be used when you need both timed and interruptible
lock acquisition.
Search WWH ::




Custom Search