The StampedLock class has other methods that you should know:
- tryReadLock() and tryReadLock(long time, TimeUnit unit): These methods try to acquire the lock in read mode. If they can't, the first version is returned immediately and the second one waits for the amount of time specified in the parameter. These methods also return a stamp that must be checked (stamp != 0).
- tryWriteLock() and tryWriteLock(long time, TimeUnit unit): These methods try to acquire the lock in write mode. If they can't, the first version is returned immediately and the second one waits for the amount of time specified in the parameter. These methods also return a stamp that must be checked (stamp != 0).
- isReadLocked() and isWriteLocked(): These methods ...