class A extends Thread { public static long x = 0; public final static long N = 10000000; public void run() { for(int i = 0; i < N; i++){ long temp = A.x + 1; A.x = temp; //A.x ++; } } public static void main(String[] args) throws Exception { A a1 = new A(); a1.start(); A a2 = new A(); a2.start(); a1.join(); a2.join(); System.out.println( A.x + " " + (A.x == 2*N) ); } }