Last active
October 23, 2018 20:18
-
-
Save exhesham/f53d3accdee1a45b99d4bb2b8e6891ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private final Lock lock = new ReentrantLock(isFair); | |
| // usage: | |
| try{ | |
| lock.lock(); | |
| // Do some stuff | |
| } finally{ | |
| lock.unlock(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); | |
| protected final Lock readLock = readWriteLock.readLock(); | |
| protected final Lock writeLock = readWriteLock.writeLock(); | |
| // usage - same idea as before! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment