ReentrantLock
-
ReentrantLock, lockInterruptibly, and tryLockStaticPL/JAVA 2020. 2. 27. 11:02
1. Overview Reentrant Locks are provided in Java to provide synchronization with greater flexibility. 2. ReentrantLock 2.1 How to use Lock lockObject = new ReentrantLock(); public int use() throws SomException { lockObject.lock(); try{ someOperations(); return value; } finally { // Ensure releasing lock even though exception occured between locking section lockObject.unlock(); } } 2.2 Why use 2...