public class SynchronizedClass { public static void main(String[] args) throws InterruptedException { countMultiple(); } static void countMultiple() throws InterruptedException { SyncCounter c = new SyncCounter(); for (int i = 0; i < 100; i++) { new Thread() { public void run() { try { c.inc(); c.dec(); } catch (InterruptedException e) { } } }.start(); } Thread.sleep(2000); System.out.println("Final: " + c.getI()); } }