Skip to content

Instantly share code, notes, and snippets.

@madhub
Created March 21, 2015 06:31
Show Gist options
  • Save madhub/e719eef74bbfb9bee281 to your computer and use it in GitHub Desktop.
Save madhub/e719eef74bbfb9bee281 to your computer and use it in GitHub Desktop.
public class LambdaDemo {
public static void withLock(ReentrantLock lock, Runnable run) {
if(lock == null || run == null){
throw new IllegalArgumentException("lock or run must not be null.");
}
lock.lock();
try {
run.run();
} finally {
lock.unlock();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment