From 6493c9a6b8aa5f55a60f1c1700f6da215c226d55 Mon Sep 17 00:00:00 2001 From: Lu <877856611@qq.com> Date: Thu, 18 Jul 2019 19:12:39 +0800 Subject: [PATCH] =?UTF-8?q?double=20check=20=E5=8F=98=E9=87=8F=E9=9C=80?= =?UTF-8?q?=E8=A6=81volatile=E4=BF=AE=E9=A5=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../escheduler/common/queue/TaskQueueZkImpl.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java b/escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java index de37b5ffce..2febb6ee13 100644 --- a/escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java +++ b/escheduler-common/src/main/java/cn/escheduler/common/queue/TaskQueueZkImpl.java @@ -17,20 +17,26 @@ package cn.escheduler.common.queue; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + import cn.escheduler.common.Constants; import cn.escheduler.common.utils.Bytes; import cn.escheduler.common.utils.IpUtils; import cn.escheduler.common.utils.OSUtils; import cn.escheduler.common.zk.AbstractZKClient; -import org.apache.commons.lang3.StringUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; - /** * A singleton of a task queue implemented with zookeeper * tasks queue implemention @@ -39,7 +45,7 @@ public class TaskQueueZkImpl extends AbstractZKClient implements ITaskQueue { private static final Logger logger = LoggerFactory.getLogger(TaskQueueZkImpl.class); - private static TaskQueueZkImpl instance; + private static volatile TaskQueueZkImpl instance; private TaskQueueZkImpl(){ init();