class IntHolder {
    int value;
    public IntHolder (int x) {
	value = x;
    }

    public void incr() {
        int j = value;
        value = j + 1;
        // value++;
    }
}
 
public class MuEx {
    public static void main (String argv []) {
	IntHolder counter = new IntHolder(0);
        
        
        MyThread thread1 = new MyThread(counter);
        MyThread thread2 = new MyThread(counter);
        thread1.start();
        thread2.start();
	try{thread1.join(0);}
        catch(InterruptedException e) {}
        
        try{thread2.join(0);}        
	catch(InterruptedException e) {}
        System.out.println("Counter " + counter.value);
    }
} 

class MyThread extends Thread {
    IntHolder localcounter;
    public MyThread (IntHolder c) {
	localcounter = c;
    }

    public void run () {
        for (int i = 0; i < 1000000; i++) {
            localcounter.incr();
	}
    }
} 
