From df48c99577f31373ead5bf76ae12db457dcbb000 Mon Sep 17 00:00:00 2001 From: Pickle <850885154@qq.com> Date: Thu, 19 Sep 2019 11:45:55 +0800 Subject: [PATCH] fix singleton with volatile (#818) --- .../src/main/java/cn/escheduler/alert/AlertServer.java | 2 +- .../java/cn/escheduler/common/thread/ThreadPoolExecutors.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java b/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java index 8de3a65d6c..27c5f0ce56 100644 --- a/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java +++ b/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java @@ -39,7 +39,7 @@ public class AlertServer { private AlertSender alertSender; - private static AlertServer instance; + private static volatile AlertServer instance; private AlertServer() { diff --git a/escheduler-common/src/main/java/cn/escheduler/common/thread/ThreadPoolExecutors.java b/escheduler-common/src/main/java/cn/escheduler/common/thread/ThreadPoolExecutors.java index 8329e8c18a..ea03026d3a 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/thread/ThreadPoolExecutors.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/thread/ThreadPoolExecutors.java @@ -40,7 +40,7 @@ public class ThreadPoolExecutors { private static final Logger logger = LoggerFactory.getLogger(ThreadPoolExecutors.class); private static Executor executor; - private static ThreadPoolExecutors threadPoolExecutors; + private static volatile ThreadPoolExecutors threadPoolExecutors; private ThreadPoolExecutors(){}