Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class MyThread extends Thread
- {
- private static Lock lock = new ReentrantLock();
- public void run()
- {
- if (MyThread.lock.tryLock())
- {
- try
- {
- // TODO something
- }
- finally
- {
- MyThread.lock.unlock();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement