Use sychronized or not below code generating same hashcode for all threads. How?
Use sychronized or not below code generating same hashcode for all threads. How? "we make the global access method synchronized so that only one thread can execute getInstance method at a time" without using synchronized keyword below code acting like threadsafe already. Car.java public class Car { private static Car car; private Car() { // TODO Auto-generated constructor stub } public static Car getInstance(){ if(car==null){ car=new Car(); } return car; } } Test.java public class Test { public static void main(String args) { Thread t1=new Thread(new Runnable() { @Override public void run() { System.out.println(Thread.currentThread().getName()+" Running"); System.out.println(Car.getInstance().hashCode()); System.out.println(Thread.currentThread().getName()+" Finishing"); } }); t1.start(); Thread t2=new Thread(new Runnable() { @Override public...