import java.util.concurrent.atomic.*;

/**
 * An application that illustrates how the AtomicInteger class can prevent
 * some of the problems that can arise
 * when using shared mutable state.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 2.0
 */
public class CounterDriver
{
    private static final int ITERATIONS = 1000000;    
    private static final int THREADS    = 5;    

    /**
     * The entry point of the application.
     *
     * @param args  The command line arguments
     */
    public static void main(String[] args)
    {
        AtomicInteger       mutable;

        mutable = new AtomicInteger(0);
        
        for (int i=0; i<THREADS; i++)
        {
            Thread thread = new Thread(new Counter(mutable, ITERATIONS));
            thread.start();
        }
    }
}
