How can you make sure that your singleton class will always return single instance in multi-threaded environment?
Answer / Rajdeep Gupta
To ensure a singleton class returns the same instance across all threads, you can use double-checked locking or enum mechanism. Another approach is using the Hungarian Hunger pattern. The key idea is to make the constructor private and provide a static method to access the single instance.
| Is This Answer Correct ? | 0 Yes | 0 No |
Is oracle charging for java?
In multi-threading how can we ensure that a resource isn't used by multiple threads simultaneously?
What is math floor in java?
Are maps ordered java?
what is difference between set and list in collection?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
What is double checked locking in singleton?
waht happens when a return type ,even void is specified for a constructor?
Can u overload main()method.Give with example.
6 Answers IBM, Schimatic Technologies,
What is parameter tag and what is its use?
What is linkedlist in java?
What is broken and continue statement?