Threads in Java


#1

How to create a thread-safe singleton in Java using double-checked locking?


#2

No, since you are obtaining lock on the say XYZ clas, only one thread will enter the synchronized block at a time. So the first thread enters then finds XYZ and creates it and then leaves the synchronized block, then the second thread enter the block then it finds that the XYZ is not null because the first thread already created it so it will not create a new instance of XYZ