Skip to content

Instantly share code, notes, and snippets.

@c2nes
Created February 26, 2013 15:24
Show Gist options
  • Save c2nes/5039265 to your computer and use it in GitHub Desktop.
Save c2nes/5039265 to your computer and use it in GitHub Desktop.
// loop until tripped, broken, interrupted, or timed out
for (;;) {
try {
if (!timed)
trip.await();
else if (nanos > 0L)
nanos = trip.awaitNanos(nanos);
} catch (InterruptedException ie) {
if (g == generation && ! g.broken) {
breakBarrier();
throw ie;
} else {
// We're about to finish waiting even if we had not
// been interrupted, so this interrupt is deemed to
// "belong" to subsequent execution.
Thread.currentThread().interrupt();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment