Movatterモバイル変換


[0]ホーム

URL:


Translate:
  • Follow Us

  • Pages

  • Find a Job
  • DFP-300×250-1

  • Newsletter Subscription

      Email

      Country


    • Jobboard

    • Can constructors be synchronized in Java?

      No, constructors can not be synchronized in Java. In fact using the keyword “synchronized” with a constructor is actually a syntax error. Remember that the “synchronized” keyword is used to prevent 2 or more threads from accessing a group of methods before one thread finishes execution in those methods.

      Does synchronizing a constructor make sense?

      Synchronizing a constructor does not make sense simply because only one thread needs to have access to a constructor. Only the thread that creates an object needs to have access to it while it is being constructed. In other words, there is no need to switch out of the constructor to another thread. Also, when the constructor is called, the object does not even exist yet.

      Hiring? Job Hunting? Post a JOB or your RESUME on our JOB BOARD >>

      Subscribe to our newsletter for more free interview questions.

      Follow @programmerintvw
      Previous...
      Next...

      Would you like to thankProgrammerInterview.com for being a helpful free resource?Then why not tell a friend about us, orsimply add a link to this page from your webpage using the HTML below.

      Link to this page:

      Please bookmark with social media, your votes are noticed and appreciated:


      [8]ページ先頭

      ©2009-2025 Movatter.jp