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
25 lines (17 loc) · 860 Bytes
/
BeanTest.java
File metadata and controls
25 lines (17 loc) · 860 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
package com.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.concurrent.ConcurrentHashMap;
import org.junit.Test;
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);
}
}