package edu.nyu.cs9053.concurrency.atomicity;

import edu.nyu.cs9053.concurrency.Concurrent;

/**
 * User: blangel
 * Date: 11/9/14
 * Time: 12:39 PM
 */
public class Atomicity {

    public static void main(String[] args) throws Exception {
        final Time time = new Time(System.currentTimeMillis());
        Runnable logic = new Runnable() {
            @Override public void run() {
                while (true) {
                    long now = time.getEpoch();
                    time.setEpoch(System.currentTimeMillis());
                    System.out.printf("%d%n", now);
                }
            }
        };
        Concurrent.run(logic, 2);
    }

}
