Java Code Examples for java.util.concurrent.ConcurrentHashMap.compute()

The following are Jave code examples for showing how to use compute() of the java.util.concurrent.ConcurrentHashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: openjdk-jdk10   File: ConcurrentHashMap8Test.java   Source Code and License Vote up 5 votes
/**
 * compute does not replace if the function returns null
 */
public void testCompute() {
    ConcurrentHashMap map = map5();
    map.compute(six, (x, y) -> null);
    assertFalse(map.containsKey(six));
}
 
Example 2
Project: openjdk-jdk10   File: ConcurrentHashMap8Test.java   Source Code and License Vote up 5 votes
/**
 * compute removes when the given key is present and function returns null
 */
public void testCompute4() {
    ConcurrentHashMap map = map5();
    map.compute(one, (x, y) -> null);
    assertFalse(map.containsKey(one));
}