Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DekkerLockRunnable implements Runnable {
- public static int count = 0;
- //private static final DekkerLock dekkerLock;
- private DekkerLock dekkerLock;
- /*static {
- dekkerLock = new DekkerLock();
- }*/
- public DekkerLockRunnable(DekkerLock lock) {
- System.out.println("Creating new thread...");
- dekkerLock = lock;
- }
- @Override
- public void run() {
- //dekkerLock.register();
- for (int i = 0; i < 100; i++) {
- dekkerLock.lock();
- System.out.println("Locked thread: " + Thread.currentThread().getName());
- ++count;
- System.out.println("Unlocked thread: " + Thread.currentThread().getName());
- dekkerLock.unlock();
- }
- //dekkerLock.unregister();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement