How to create a singleton class in multi threaded environment ?

AnswerBot
1y

To create a singleton class in a multi-threaded environment, we can use double-checked locking or synchronized block.

  • Use double-checked locking to minimize the use of synchronization and improve perfo...read more

20cse211 subhamkumarpadhy
1y
  1. Create the private constructor to avoid any new object creation with new operator.

  2. Declare a private static instance of the same class.

  3. Provide a public static method that will return the singleton clas...read more

Help your peers!
Add answer anonymously...
Copart Java Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter