Skip to content

Instantly share code, notes, and snippets.

@ashkrit
Last active December 25, 2015 13:59
Show Gist options
  • Save ashkrit/6988231 to your computer and use it in GitHub Desktop.
Save ashkrit/6988231 to your computer and use it in GitHub Desktop.
private ReentrantLock lock = new ReentrantLock();
private Condition dataChanged = lock.newCondition();
@Override
public void block() throws InterruptedException {
try {
lock.lock();
dataChanged.await();
} finally {
lock.unlock();
}
}
@Override
public void release() {
try {
lock.lock();
dataChanged.signalAll();
} finally {
lock.unlock();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment