forked from qiujiayu/AutoLoadCache
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeanTest.java
More file actions
27 lines (20 loc) · 891 Bytes
/
Copy pathBeanTest.java
File metadata and controls
27 lines (20 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.concurrent.ConcurrentHashMap;
import org.junit.Test;
/**
* @author: jiayu.qiu
*/
public class BeanTest {
private static final ConcurrentHashMap<String, Boolean> PROCESSING=new ConcurrentHashMap<String, Boolean>();
@Test
public void testputIfAbsent() {
Boolean isProcessing=PROCESSING.putIfAbsent("k1", Boolean.TRUE);// 为发减少数据层的并发,增加等待机制。
assertNull(isProcessing);
System.out.println("isProcessing1==" + isProcessing);
isProcessing=PROCESSING.putIfAbsent("k1", Boolean.TRUE);// 为发减少数据层的并发,增加等待机制。
System.out.println("isProcessing2==" + isProcessing);
assertEquals(isProcessing, Boolean.TRUE);
}
}