Thread 1 exits the synchronized block and returns instance from the getInstance() method.
线程1退出synchronized块并从getInstance()方法返回实例。
Also, each Home instance is cached once found, so that subsequent lookups will obtain it from the cache, and this cache access is protected with a synchronized block.
而且,一旦找到缓存的主机实例,随后的查找都可以从缓存中获取,这种缓存访问受到同步块的保护。
Then, one thread enters the synchronized block to initialize instance, while the other is blocked.
然后,一个线程进入synchronized块来初始化instance,而另一个线程则被阻断。
Note that when the second thread enters the synchronized block, it does not check to see if instance is non-null.
注意:当第二个线程进入synchronized块时,它并没有检查instance是否非null。
Note that when the second thread enters the synchronized block, it does not check to see if instance is non-null.
注意:当第二个线程进入synchronized块时,它并没有检查instance是否非null。
应用推荐