// Path: COSC111/src/edu/java/cosc111/samples/concurrency/sync/SyncCounter.java
// public class SyncCounter implements Counter{
//     private int nCurCount;
//     private final int MAX_COUNT;
//     private final Object lck = new Object();
//     
//     public SyncCounter(){
//         this(Integer.MAX_VALUE);
//     }
//     
//     public SyncCounter(int limit){
//         if(limit>=0){
//             MAX_COUNT = limit;
//         }else{
//             MAX_COUNT = Integer.MAX_VALUE;
//         }
//     }
//     
//     public synchronized int increment(){        
//             //Critical section
//             if(!isMaxed()){            
//                 nCurCount = nCurCount + 1;
//             }            
//         return nCurCount;
//     }
//     
//     public synchronized int getCount(){
//         return nCurCount;
//     }
//     
//     public synchronized boolean isMaxed(){
//         return nCurCount == MAX_COUNT;
//     }
// 
//     private void delay(){
//         ThreadLocalRandom r = ThreadLocalRandom.current();
//         try {
//             //Simulate long computation
//             Thread.sleep(r.nextLong(1000L, 1500L));
//         } catch (InterruptedException ex) {}
//     }
// }


import edu.java.cosc111.samples.concurrency.sync.SyncCounter;
import java.util.Scanner;

package edu.java.cosc111.samples.concurrency;


public class IncrementerSync {
    public static void main(String[] args) throws InterruptedException {
        Scanner in = new Scanner(System.in);
        
//        System.out.print("Number of threads: ");

// Path: COSC111/src/edu/java/cosc111/samples/concurrency/sync/SyncCounter.java
// public class SyncCounter implements Counter{
//     private int nCurCount;
//     private final int MAX_COUNT;
//     private final Object lck = new Object();
//     
//     public SyncCounter(){
//         this(Integer.MAX_VALUE);
//     }
//     
//     public SyncCounter(int limit){
//         if(limit>=0){
//             MAX_COUNT = limit;
//         }else{
//             MAX_COUNT = Integer.MAX_VALUE;
//         }
//     }
//     
//     public synchronized int increment(){        
//             //Critical section
//             if(!isMaxed()){            
//                 nCurCount = nCurCount + 1;
//             }            
//         return nCurCount;
//     }
//     
//     public synchronized int getCount(){
//         return nCurCount;
//     }
//     
//     public synchronized boolean isMaxed(){
//         return nCurCount == MAX_COUNT;
//     }
// 
//     private void delay(){
//         ThreadLocalRandom r = ThreadLocalRandom.current();
//         try {
//             //Simulate long computation
//             Thread.sleep(r.nextLong(1000L, 1500L));
//         } catch (InterruptedException ex) {}
//     }
// }


// Path: COSC111/src/edu/java/cosc111/samples/concurrency/IncrementerSync.java
import edu.java.cosc111.samples.concurrency.sync.SyncCounter;
import java.util.Scanner;

package edu.java.cosc111.samples.concurrency;


public class IncrementerSync {
    public static void main(String[] args) throws InterruptedException {
        Scanner in = new Scanner(System.in);
        
//        System.out.print("Number of threads: ");

        int n = 100;//in.nextInt();
