Skip to content

Instantly share code, notes, and snippets.

@luctrudeau
Created November 7, 2008 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luctrudeau/22766 to your computer and use it in GitHub Desktop.
Save luctrudeau/22766 to your computer and use it in GitHub Desktop.
Lock lock = ...;
if (lock.tryLock()) {
try {
// manipulate protected state
} finally {
lock.unlock();
}
} else {
// perform alternative actions
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment