import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; ConcurrentLinkedHashMap<String, Integer> map = new ConcurrentLinkedHashMap.Builder<String, Integer>() .maximumWeightedCapacity(100) .build(); for (int i = 0; i < 100; i++) { final int index = i; new Thread(() -> { map.put("Key" + index, index); }).start(); } for (int i = 0; i < 100; i++) { final int index = i; new Thread(() -> { Integer value = map.get("Key" + index); System.out.println("Key" + index + ": " + value); }).start(); }


上一篇:
下一篇:
切换中文