Skip to content

Instantly share code, notes, and snippets.

@kaedea
Created September 13, 2016 09:13
Show Gist options
  • Save kaedea/2e2012d004a624074f357ed619f621e1 to your computer and use it in GitHub Desktop.
Save kaedea/2e2012d004a624074f357ed619f621e1 to your computer and use it in GitHub Desktop.
Synchronize helper class in TestCase.
public class Latch {
volatile boolean isNotified;
public synchronized void tryNotify() {
isNotified = true;
notify();
}
public synchronized void tryWait(long millis) {
try {
isNotified = false;
wait(millis);
} catch (InterruptedException ignore) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment