Last active
December 25, 2015 13:59
-
-
Save ashkrit/6988231 to your computer and use it in GitHub Desktop.
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 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