1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

Merge pull request #822 from huangshangi/master

Update the singleton pattern example
This commit is contained in:
SnailClimb 2020-06-17 18:41:57 +08:00 committed by GitHub
commit d223864a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@ public class Singleton {
private Singleton() { private Singleton() {
} }
public synchronized static Singleton getUniqueInstance() { public static Singleton getUniqueInstance() {
//先判断对象是否已经实例过,没有实例化过才进入加锁代码 //先判断对象是否已经实例过,没有实例化过才进入加锁代码
if (uniqueInstance == null) { if (uniqueInstance == null) {
//类对象加锁 //类对象加锁