Tag Archives: Constructor

Java Constructors can not be Synchronized

We synchronize a method to ensure that only a single thread can execute the statements in the method at a timeĀ  , thread automatically acquires lock on the object used for invoking the synchronize method
Since an object will never exist until and unless the constructor is called and constructor can not be called twice for the same instance,same obect there is no sense of synchronizing a constructor as two threads will never be able to execute it on the same instance ,although we can have a synchronize block inside the constructor