Last active
October 23, 2018 20:18
Star
You must be signed in to star a gist
This file contains 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 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