It's a game we invented by accident by making you put the threads window next to the stack window, and double clicking on each thread to find the one you want.
If this code is interrupted by another thread after executing line C3 but before completing the constructor, double-checked locking fails.
如果此代码在执行c 3行后且在完成该构造函数前被另一个线程中断,则双重检查锁定就会失败。
3
Instead of double-checked locking, use the Initialize-on-demand Holder Class idiom, which provides lazy initialization, is thread-safe, and is faster and less confusing than double-checked locking.
不使用双重检查锁定,而使用Initialize - on - demand Holder Class idiom,它提供了迟缓初始化,是线程安全的,而且比双重检查锁定更快且没那么混乱。