From 5050c68637f258456b8352269b9fb4e88872e28a Mon Sep 17 00:00:00 2001 From: javahongxi Date: Tue, 13 Aug 2019 08:50:13 +0800 Subject: [PATCH] optimise --- .../common/util/concurrent/ConcurrentTreeMap.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/whatsmars-common/src/main/java/org/hongxi/whatsmars/common/util/concurrent/ConcurrentTreeMap.java b/whatsmars-common/src/main/java/org/hongxi/whatsmars/common/util/concurrent/ConcurrentTreeMap.java index 8bbfd088..d576996a 100644 --- a/whatsmars-common/src/main/java/org/hongxi/whatsmars/common/util/concurrent/ConcurrentTreeMap.java +++ b/whatsmars-common/src/main/java/org/hongxi/whatsmars/common/util/concurrent/ConcurrentTreeMap.java @@ -28,19 +28,19 @@ public class ConcurrentTreeMap { } } - public V putIfAbsentAndRetExsit(K key, V value) { + public V putIfAbsent(K key, V value) { lock.lock(); try { if (roundQueue.put(key)) { - V exsit = tree.get(key); - if (null == exsit) { + V oldValue = tree.get(key); + if (null == oldValue) { tree.put(key, value); - exsit = value; + oldValue = value; } - return exsit; + return oldValue; } else { - V exsit = tree.get(key); - return exsit; + V oldValue = tree.get(key); + return oldValue; } } finally { lock.unlock(); -- GitLab