Forums Java Help Can we synchronize the constructor of a Java Class?

This topic contains 1 reply, has 1 voice, and was last updated by  Aakanksha 8 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3794

    Aakanksha
    Participant

    Can we synchronize the constructor of a Java Class?

    #11527

    Aakanksha
    Participant

    As per Java Language Specification, constructors cannot be synchronized because other threads cannot see the object being created before the thread creating it has finished it. There is no practical need of a Java Objects constructor to be synchronized, since it would lock the object being constructed, which is normally not available to other threads until all constructors of the object finish.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.