Skip to content

Instantly share code, notes, and snippets.

@exhesham

exhesham/lock.java

Last active Oct 23, 2018
Embed
What would you like to do?
private final Lock lock = new ReentrantLock(isFair);
// usage:
try{
lock.lock();
// Do some stuff
} finally{
lock.unlock();
}
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
You can’t perform that action at this time.