package edu.nyu.cs9053.concurrency.chapter14.suspend;

import java.util.concurrent.locks.Lock;

/**
 * User: blangel
 * Date: 7/26/14
 * Time: 2:11 PM
 */
public class ThreadSuspend implements Runnable {

    private final Lock lock;

    public ThreadSuspend(Lock lock) {
        this.lock = lock;
    }

    @Override public void run() {
        while (!Thread.currentThread().isInterrupted()) {
            lock.lock();
            try {
                System.out.println("Alive!");
            } finally {
                lock.unlock();
            }
        }
    }
}
