Package com.iizix
Class AutoLock
java.lang.Object
com.iizix.AutoLock
- All Implemented Interfaces:
- Serializable,- AutoCloseable
Reentrant lock that can be used in a try-with-resources statement.
Typical usage:
 try (AutoLock lock=this.lock.lock())
   {
   // Something
   }
 - See Also:
- Constructor Details- AutoLockpublic AutoLock()Constructs the reentrant lock, unlocked.
 
- Method Details- lock- Acquires the lock. - Returns:
- thisAutoLock for unlocking.
 
- isHeldByCurrentThreadpublic boolean isHeldByCurrentThread()Queries if this lock is held by the current thread.- Returns:
- Whether this lock is held by the current thread.
- See Also:
 
- closepublic void close()(Auto) closes the instance by unlocking the reentrant lock.- Specified by:
- closein interface- AutoCloseable