I have the following code:
public class MyThread extends Thread { private int i; public static int sum=0; public MyThread(int k){ i=k; }
The synchronization on methods only holds for invocations of the same object. You are creating two different objects (the two threads).