package edu.nyu.cs9053.concurrency.chapter14;

/**
 * User: blangel
 * Date: 7/26/14
 * Time: 10:47 AM
 */
public class Synchronized {

    private int value;

    public void print() throws InterruptedException {
        synchronized (this) {
            while (value < 100) {
                wait();
            }
            System.out.printf("Value is %d%n", value);
        }
    }

    public void process() {
        synchronized (this) {
            value += 1;
            notifyAll();
        }
    }

}
