class ThreadSafeClass extends Thread { private static int count = 0; public synchronized static void increment() { count++; } public
Since two different methods, one is instance level and other is class level, so you need to lock on 2 different objects to make it ThreadSafe