提交 5050c686 编写于 作者: 武汉红喜's avatar 武汉红喜

optimise

上级 d16775b8
...@@ -28,19 +28,19 @@ public class ConcurrentTreeMap<K, V> { ...@@ -28,19 +28,19 @@ public class ConcurrentTreeMap<K, V> {
} }
} }
public V putIfAbsentAndRetExsit(K key, V value) { public V putIfAbsent(K key, V value) {
lock.lock(); lock.lock();
try { try {
if (roundQueue.put(key)) { if (roundQueue.put(key)) {
V exsit = tree.get(key); V oldValue = tree.get(key);
if (null == exsit) { if (null == oldValue) {
tree.put(key, value); tree.put(key, value);
exsit = value; oldValue = value;
} }
return exsit; return oldValue;
} else { } else {
V exsit = tree.get(key); V oldValue = tree.get(key);
return exsit; return oldValue;
} }
} finally { } finally {
lock.unlock(); lock.unlock();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册