Created
March 21, 2015 06:31
-
-
Save madhub/e719eef74bbfb9bee281 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
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