Breaking News: Grepper is joining Read the official announcement!
Check it out

Can we mark a constructor as synchronized in Java?

Pragya Keshap answered on February 4, 2023 Popularity 3/10 Helpfulness 4/10


More Related Answers

  • java normal constructor
  • type of constructor in java
  • synchronized java
  • synchronized block java
  • java call another constructor
  • how to create a constructor in java
  • Synchronized Block in Java
  • what is constructor in java
  • Java Synchronized Method
  • syntax of a constructor in java
  • can a java class have more than 108 constructors
  • calling this in constructor java
  • Constructors in Java
  • what is constructor in java
  • java two constructors
  • Synchronized Method in Java
  • java constructor example
  • different constructiors in java and what they do explained
  • Can we use synchronized block for primitives?
  • Using synchronized keyword
  • Calling constructor methods in java
  • constructors java

  • Can we mark a constructor as synchronized in Java?


    No. We cannot mark a constructor as synchronized.

    This will lead to compiler error.

    The reasoning behind this is that, in this case, only the constructing

    thread would have access to the object being constructed

    Popularity 3/10 Helpfulness 4/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 04 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.