InterviewSolution
Saved Bookmarks
| 1. |
Can You Write Thread-safe Singleton In Java? |
|
Answer» There are multiple ways to write thread-safe singleton in Java e.g by writing singleton using double checked LOCKING, by using STATIC Singleton instance initialized during class loading. By the way using Java enum to CREATE thread-safe singleton is most SIMPLE way. There are multiple ways to write thread-safe singleton in Java e.g by writing singleton using double checked locking, by using static Singleton instance initialized during class loading. By the way using Java enum to create thread-safe singleton is most simple way. |
|