Computing Magazine
What would be the output of the following program ? public class ThreadTest implements Runnable{ private Object obj=new Object(); public static void main(String[] args) { ThreadTest test = new ThreadTest(); Thread t1 = new Thread(test); Thread t2 = new Thread(test); t1.start(); t2.start(); } @Override public void run() { synchronized(obj) { System.out.println("1 " + Thread.currentThread().getId()); obj = new Object(); System.out.println("2 " +Thread.currentThread().getId()); } }}