Skip to content

Instantly share code, notes, and snippets.

@exhesham
Last active October 23, 2018 20:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save exhesham/f53d3accdee1a45b99d4bb2b8e6891ce to your computer and use it in GitHub Desktop.
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