From e88e2892eaed5f8d030210394f4925bf915ba02a Mon Sep 17 00:00:00 2001 From: huangshangi <38102027+huangshangi@users.noreply.github.com> Date: Tue, 16 Jun 2020 10:21:01 +0800 Subject: [PATCH] Update JavaConcurrencyAdvancedCommonInterviewQuestions.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 单例模式实例修改,在单例方法上声明synchronized关键字是不必要的且会造成性能上的开销 --- .../JavaConcurrencyAdvancedCommonInterviewQuestions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/java/Multithread/JavaConcurrencyAdvancedCommonInterviewQuestions.md b/docs/java/Multithread/JavaConcurrencyAdvancedCommonInterviewQuestions.md index 68878b94..8c5a30a6 100644 --- a/docs/java/Multithread/JavaConcurrencyAdvancedCommonInterviewQuestions.md +++ b/docs/java/Multithread/JavaConcurrencyAdvancedCommonInterviewQuestions.md @@ -73,7 +73,7 @@ public class Singleton { private Singleton() { } - public synchronized static Singleton getUniqueInstance() { + public static Singleton getUniqueInstance() { //先判断对象是否已经实例过,没有实例化过才进入加锁代码 if (uniqueInstance == null) { //类对象加锁