﻿{"id":2048,"date":"2015-06-13T22:45:03","date_gmt":"2015-06-13T13:45:03","guid":{"rendered":"http:\/\/yucchi.jp\/blog\/?p=2048"},"modified":"2015-06-13T22:54:40","modified_gmt":"2015-06-13T13:54:40","slug":"java-8-%e6%99%82%e4%bb%a3%e3%81%ae-concurrenthashmap-%e3%81%a7%e9%81%8a%e3%82%93%e3%81%a7%e3%81%bf%e3%81%9f%e3%80%82","status":"publish","type":"post","link":"http:\/\/yucchi.jp\/blog\/?p=2048","title":{"rendered":"Java 8 \u6642\u4ee3\u306e ConcurrentHashMap \u3067\u904a\u3093\u3067\u307f\u305f\u3002"},"content":{"rendered":"<p>\u307e\u305f\u307e\u305f Blog \u306e\u66f4\u65b0\u3092\u3055\u307c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3068\u8a00\u3046\u3053\u3068\u3067\u9069\u5f53\u306a\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u66f8\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><strong><font color=\"#ff0000\" size=\"5\">ConcurrentHashMap<\/font><\/strong><\/p>\n<p>J2SE5.0 \u3067 java.util.concurrent \u306b ConcurrentHashMap \u304c\u5c0e\u5165\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>ConcurrentHashMap \u306f\u5bb9\u6613\u306b\u5b89\u5168\u306b\u4e26\u884c\u51e6\u7406\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u4f5c\u3089\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>Collections.synchronizedMap \u3063\u3066\u306e\u3082\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u306f\u4f7f\u3044\u65b9\u304c\u5fae\u5999\u3067\u8a73\u3057\u3044\u8aac\u660e\u306f\u7701\u7565\u3057\u307e\u3059\u304c Iterator \u306a\u3069\u306e\u53cd\u5fa9\u51e6\u7406\u3067 ConcurrentModificationException \u3092\u30b9\u30ed\u30fc\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>Collections.synchronizedMap \u306f\u3001Map \u306e\u30ed\u30c3\u30af\u3092\u53d6\u5f97\u3059\u308b\u3068\u4ed6\u306e\u30b9\u30ec\u30c3\u30c9\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3092\u7981\u3058\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>ConcurrentHashMap \u3060\u3068\u3001Iterator \u304a\u3088\u3073 Enumeration \u306f\u3001\u3042\u308b\u6642\u70b9\u307e\u305f\u306f\u53cd\u5fa9\u5b50\/\u5217\u6319\u306e\u4f5c\u6210\u4ee5\u964d\u306e\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u306e\u72b6\u614b\u3092\u53cd\u6620\u3059\u308b\u8981\u7d20\u3092\u8fd4\u3059\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001<\/p>\n<p>ConcurrentModificationException \u3092\u30b9\u30ed\u30fc\u3059\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u4e00\u5ea6\u306b 1 \u3064\u306e\u30b9\u30ec\u30c3\u30c9\u3060\u3051\u3057\u304b\u53cd\u5fa9\u5b50\u3092\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3042\u3068\u3001HashMap \u306f\u30a8\u30f3\u30c8\u30ea\u30fc\u306e\u30ad\u30fc\u3084\u5024\u306bnull\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u304c\u3001ConcurrentHashMap\u3067\u306f\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>NullPointerException \u304c\u6295\u3052\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>ConcurrentHashMap \u306f\u3001HashMap \u306e\u3088\u3046\u306a\u30cf\u30c3\u30b7\u30e5\u3092\u4f7f\u3063\u305f Map \u3067\u3059\u304c\u30ed\u30c3\u30af\u30b9\u30c8\u30e9\u30a4\u30d4\u30f3\u30b0\u3068\u8a00\u308f\u308c\u308b\u7c92\u5ea6\u306e\u5c0f\u3055\u306a\u30ed\u30c3\u30af\u65b9\u5f0f\u3092\u63a1\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001Map \u5168\u4f53\u3092\u30ed\u30c3\u30af\u3057\u3066\u6392\u4ed6\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5fc5\u8981\u304c\u306a\u3051\u308c\u3070&nbsp; ConcurrentHashMap \u306f\u3001\u3068\u3066\u3082\u9b45\u529b\u7684\u306a\u5b58\u5728\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001J2SE5.0 \u306e\u6642\u306b\u306f\u3001ConcurrentHashMap \u3092\u4fbf\u5229\u306b\u4f7f\u3046\u306b\u306f\u307e\u3060\u307e\u3060\u30d1\u30fc\u30c4\u304c\u63c3\u3063\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u4fbf\u5229\u306b\u4f7f\u3048\u305d\u3046\u3060\u3063\u305f\u306e\u306f\u30a2\u30c8\u30df\u30c3\u30af\u306b\u5b9f\u884c\u3055\u308c\u308b\u4e0b\u8a18\u30e1\u30bd\u30c3\u30c9\u304f\u3089\u3044\u3067\u3057\u305f\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">public V putIfAbsent(K key, V value)<\/font><\/p>\n<p><font color=\"#666666\">public boolean remove(Object key, Object value)<\/font><\/p>\n<p><font color=\"#666666\">public V replace(K key, V value)<\/font><\/p>\n<p><font color=\"#666666\">public boolean replace(K key, V oldValue, V newValue)<\/font><\/p>\n<\/blockquote>\n<p>\u307e\u305f\u53e4\u3044 J2SE5.0 \u30cd\u30bf\u304b\u3068\u601d\u308f\u305b\u3066\u3001\u3053\u3053\u304b\u3089\u6700\u65b0\u306e Java SE 8 \u30cd\u30bf\u3067\u3059\u3002<\/p>\n<p>Java SE 8 \u3067 ConcurrentHashMap \u306b\u8ffd\u52a0\u3055\u308c\u305f\u4fbf\u5229\u306a\u6a5f\u80fd\u3092\u3044\u304f\u3064\u304b\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u306f\u3058\u3081\u306b\u3001ConcurrentHashMap \u3068\u3044\u3046\u30cd\u30fc\u30df\u30f3\u30b0\u304b\u3089\u4f55\u3092\u3084\u3063\u3066\u3082\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u3060\u3068\u601d\u3044\u8fbc\u3093\u3067\u3057\u307e\u3046\u3068\u6ce3\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4e0b\u8a18\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u3088\u3046\u306b\u8907\u6570\u30b9\u30ec\u30c3\u30c9\u304b\u3089 ConcurrentHashMap \u306e\u5024\u306e\u66f4\u65b0\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u7d42\u7684\u306b Key \u201cHOGE\u201d, Value \u306f 80 \u3068\u306a\u308b\u3053\u3068\u3092\u671f\u5f85\u3057\u307e\u3059\u304c\u6b8b\u5ff5\u306a\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><pre title=\"Counter.java\">\r\npackage jp.yucchi.concurrenthashmapexample0;\r\n\r\nimport java.util.Random;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\nimport java.util.concurrent.TimeUnit;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\nclass Counter {\r\n\r\n    ConcurrentHashMap<String, Integer> map;\r\n    private Random random = new Random();\r\n\r\n    public Counter(ConcurrentHashMap<String, Integer> map) {\r\n        this.map = map;\r\n    }\r\n\r\n    void incrementCounter() {\r\n        for (int i = 0; i < 10; i++) {\r\n            try {\r\n                TimeUnit.MILLISECONDS.sleep(random.nextInt(50));\r\n            } catch (InterruptedException ex) {\r\n                Logger.getLogger(Counter.class.getName()).log(Level.SEVERE, null, ex);\r\n            }\r\n            int counter = map.get(\"HOGE\");\r\n            map.put(\"HOGE\", ++counter);\r\n        }\r\n        System.out.println(Thread.currentThread().getName() + \": HOGE, \" + map.get(\"HOGE\"));\r\n    }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n<pre title=\"ConcurrentHashMapExample0.java\">\r\npackage jp.yucchi.concurrenthashmapexample0;\r\n\r\nimport java.util.concurrent.CompletableFuture;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\npublic class ConcurrentHashMapExample0 {\r\n\r\n    public static void main(String[] args) {\r\n\r\n        ConcurrentHashMap<String, Integer> count = new ConcurrentHashMap<>();\r\n        count.put(\"HOGE\", 0);\r\n\r\n        Counter counter = new Counter(count);\r\n\r\n        CompletableFuture<Void> cnt_1 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_2 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_3 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_4 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_5 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_6 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_7 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_8 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n\r\n        CompletableFuture<Void> allTask = CompletableFuture.allOf(cnt_1, cnt_2, cnt_3, cnt_4, cnt_5, cnt_6, cnt_7, cnt_8);\r\n        allTask.join();\r\n\r\n        if (allTask.isDone()) {\r\n            count.forEach(1, (key, value) -> {\r\n                System.out.println(Thread.currentThread().getName() + \" : \" + key + \", \" + value);\r\n            });\r\n        }\r\n    }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>ForkJoinPool.commonPool-worker-18: HOGE, 48<br \/>ForkJoinPool.commonPool-worker-29: HOGE, 58<br \/>ForkJoinPool.commonPool-worker-8: HOGE, 65<br \/>ForkJoinPool.commonPool-worker-4: HOGE, 67<br \/>ForkJoinPool.commonPool-worker-11: HOGE, 68<br \/>ForkJoinPool.commonPool-worker-15: HOGE, 70<br \/>ForkJoinPool.commonPool-worker-25: HOGE, 73<br \/>ForkJoinPool.commonPool-worker-22: HOGE, 75<br \/>main : HOGE, 75<\/p>\n<p>\u66f4\u65b0\u51e6\u7406\u307e\u3067\u306f\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u3067\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3069\u306e\u3088\u3046\u306b\u5bfe\u51e6\u3059\u308c\u3070\u3044\u3044\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>java.util.concurrent.atomic.LongAdder \u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>LongAdder \u30af\u30e9\u30b9\u306f\u3001\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306b\u5bfe\u3059\u308b\u30a2\u30c8\u30df\u30c3\u30af\u64cd\u4f5c\u3092\u884c\u3046\u305f\u3081 Java SE 8 \u304b\u3089\u8ffd\u52a0\u3055\u308c\u305f\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<p>LongAdder \u30af\u30e9\u30b9\u306b\u306f\u3001add(1)\u3068\u7b49\u4fa1\u306a increment() \u30e1\u30bd\u30c3\u30c9\u3068\u3001add(-1)\u3068\u7b49\u4fa1\u306a decrement() \u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>LongAdder \u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u4fee\u6b63\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><pre title=\"Counter.java\">\r\npackage jp.yucchi.concurrenthashmapexample1;\r\n\r\nimport java.util.Random;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\nimport java.util.concurrent.TimeUnit;\r\nimport java.util.concurrent.atomic.LongAdder;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\nclass Counter {\r\n\r\n    ConcurrentHashMap<String, LongAdder> map;\r\n    private Random random = new Random();\r\n\r\n    public Counter(ConcurrentHashMap<String, LongAdder> map) {\r\n        this.map = map;\r\n    }\r\n\r\n    void incrementCounter() {\r\n        for (int i = 0; i < 10; i++) {\r\n            try {\r\n                TimeUnit.MILLISECONDS.sleep(random.nextInt(50));\r\n            } catch (InterruptedException ex) {\r\n                Logger.getLogger(Counter.class.getName()).log(Level.SEVERE, null, ex);\r\n            }\r\n            map.get(\"HOGE\").increment();\r\n        }\r\n        System.out.println(Thread.currentThread().getName() + \": HOGE, \" + map.get(\"HOGE\"));\r\n    }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n<pre title=\"ConcurrentHashMapExample1.java\">\r\nimport java.util.concurrent.CompletableFuture;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\nimport java.util.concurrent.atomic.LongAdder;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\npublic class ConcurrentHashMapExample1 {\r\n\r\n    public static void main(String[] args) {\r\n\r\n        ConcurrentHashMap<String, LongAdder> count = new ConcurrentHashMap<>();\r\n        count.put(\"HOGE\", new LongAdder());\r\n\r\n        Counter counter = new Counter(count);\r\n\r\n        CompletableFuture<Void> cnt_1 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_2 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_3 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_4 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_5 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_6 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_7 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_8 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n\r\n        CompletableFuture<Void> allTask = CompletableFuture.allOf(cnt_1, cnt_2, cnt_3, cnt_4, cnt_5, cnt_6, cnt_7, cnt_8);\r\n        allTask.join();\r\n\r\n        if (allTask.isDone()) {\r\n            count.forEach(1, (key, value) -> {\r\n                System.out.println(Thread.currentThread().getName() + \" : \" + key + \", \" + value);\r\n            });\r\n        }\r\n    }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>ForkJoinPool.commonPool-worker-25: HOGE, 49<br \/>ForkJoinPool.commonPool-worker-18: HOGE, 63<br \/>ForkJoinPool.commonPool-worker-11: HOGE, 71<br \/>ForkJoinPool.commonPool-worker-4: HOGE, 72<br \/>ForkJoinPool.commonPool-worker-29: HOGE, 73<br \/>ForkJoinPool.commonPool-worker-8: HOGE, 78<br \/>ForkJoinPool.commonPool-worker-15: HOGE, 79<br \/>ForkJoinPool.commonPool-worker-22: HOGE, 80<br \/>main : HOGE, 80<\/p>\n<p>\u671f\u5f85\u901a\u308a\u306b\u3046\u3054\u3044\u3066\u304f\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u3082\u3001ConcurrentHashMap&lt;String, LongAdder&gt; \u3068\u304b\u306b\u5909\u66f4\u3059\u308b\u306e\u3082\u9762\u5012\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001Java SE 8 \u3067\u306e\u3082\u3063\u3068\u7d20\u6575\u306a\u4fee\u6b63\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30a2\u30c8\u30df\u30c3\u30af\u64cd\u4f5c\u3092\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">public V compute(K key, BiFunction&lt;? super K,? super V,? extends V&gt; remappingFunction)<\/font><\/p>\n<p><font color=\"#666666\">public V computeIfPresent(K key, BiFunction&lt;? super K,? super V,? extends V&gt; remappingFunction)<\/font><\/p>\n<p><font color=\"#666666\">public V merge(K key, V value, BiFunction&lt;? super V,? super V,? extends V&gt; remappingFunction)<\/font><\/p>\n<\/blockquote>\n<p>compute \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u3068\u73fe\u5728\u30de\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u5024\u306b\u5bfe\u3059\u308b\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u8a08\u7b97\u3092\u8a66\u307f\u307e\u3059(\u73fe\u5728\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f<code>null<\/code>)\u3002<\/p>\n<p>computeIfPresent \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u306e\u5024\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u30ad\u30fc\u3068\u73fe\u5728\u30de\u30c3\u30d7\u3055\u308c\u3066\u3044\u308b\u5024\u304b\u3089\u65b0\u3057\u3044\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u8a08\u7b97\u3092\u8a66\u307f\u307e\u3059\u3002<\/p>\n<p>merge \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u30ad\u30fc\u304c\u307e\u3060(null\u3067\u306a\u3044)\u5024\u3068\u95a2\u9023\u4ed8\u3051\u3089\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u5024\u306b\u95a2\u9023\u4ed8\u3051\u307e\u3059\u3002\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306f\u3001\u6307\u5b9a\u3055\u308c\u305f\u518d\u30de\u30c3\u30d4\u30f3\u30b0\u95a2\u6570\u306e\u7d50\u679c\u3067\u5024\u3092\u7f6e\u63db\u3057\u3001<code>null<\/code>\u306e\u5834\u5408\u306f\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001computeIfPresent \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4ed6\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u4f7f\u7528\u4f8b\u306f\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u8a18\u8ff0\u3057\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><pre title=\"Counter.java\">\r\npackage jp.yucchi.concurrenthashmapexample2;\r\n\r\nimport java.util.Random;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\nimport java.util.concurrent.TimeUnit;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\nclass Counter {\r\n\r\n    ConcurrentHashMap<String, Integer> map;\r\n    private Random random = new Random();\r\n\r\n    public Counter(ConcurrentHashMap<String, Integer> map) {\r\n        this.map = map;\r\n    }\r\n\r\n    void incrementCounter() {\r\n        for (int i = 0; i < 10; i++) {\r\n            try {\r\n                TimeUnit.MILLISECONDS.sleep(random.nextInt(50));\r\n            } catch (InterruptedException ex) {\r\n                Logger.getLogger(Counter.class.getName()).log(Level.SEVERE, null, ex);\r\n            }\r\n\r\n            map.computeIfPresent(\"HOGE\", (k, v) -> ++v);\r\n\/\/            map.compute(\"HOGE\", (k, v) -> ++v);\r\n\/\/            map.merge(\"HOGE\", 1, Integer::sum);\r\n\r\n        }\r\n        System.out.println(Thread.currentThread().getName() + \": HOGE, \" + map.get(\"HOGE\"));\r\n    }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n<pre title=\"ConcurrentHashMapExample2.java\">\r\npackage jp.yucchi.concurrenthashmapexample2;\r\n\r\nimport java.util.concurrent.CompletableFuture;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\npublic class ConcurrentHashMapExample2 {\r\n\r\n    \/**\r\n     * @param args the command line arguments\r\n     *\/\r\n    public static void main(String[] args) {\r\n\r\n        ConcurrentHashMap<String, Integer> count = new ConcurrentHashMap<>();\r\n        count.put(\"HOGE\", 0);\r\n\r\n        Counter counter = new Counter(count);\r\n        \r\n        CompletableFuture<Void> cnt_1 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_2 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_3 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_4 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_5 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_6 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_7 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n        CompletableFuture<Void> cnt_8 = CompletableFuture.runAsync(() -> counter.incrementCounter());\r\n\r\n        CompletableFuture<Void> allTask = CompletableFuture.allOf(cnt_1, cnt_2, cnt_3, cnt_4, cnt_5, cnt_6, cnt_7, cnt_8);\r\n        allTask.join();\r\n\r\n        if (allTask.isDone()) {\r\n            count.forEach(1, (key, value) -> {\r\n                System.out.println(Thread.currentThread().getName() + \" : \" + key + \", \" + value);\r\n            });\r\n        }\r\n    }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>ForkJoinPool.commonPool-worker-4: HOGE, 59<br \/>ForkJoinPool.commonPool-worker-15: HOGE, 61<br \/>ForkJoinPool.commonPool-worker-18: HOGE, 62<br \/>ForkJoinPool.commonPool-worker-22: HOGE, 68<br \/>ForkJoinPool.commonPool-worker-11: HOGE, 74<br \/>ForkJoinPool.commonPool-worker-25: HOGE, 78<br \/>ForkJoinPool.commonPool-worker-8: HOGE, 79<br \/>ForkJoinPool.commonPool-worker-29: HOGE, 80<br \/>main : HOGE, 80<\/p>\n<p>\u3053\u308c\u307e\u3067\u306e\u3068\u3053\u308d\u306f J2SE5.0 \u3067\u3082\u6ce8\u610f\u304c\u5fc5\u8981\u3067 replace \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u65b9\u6cd5\u3001AtomicLong \u3092\u4f7f\u3046\u306a\u3069\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>Java SE 8 \u3067\u306f\u7dba\u9e97\u306b\u305d\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u306d\uff01<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u3053\u308c\u304b\u3089 Java SE 8 \u3067\u8ffd\u52a0\u3055\u308c\u305f\u30b9\u30ec\u30c3\u30c9\u30bb\u30fc\u30d5\u306a\u30d0\u30eb\u30af\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u7d44\u3093\u3067\u3001Java SE 8 \u3067 ConcurrentHashMap \u306b\u8ffd\u52a0\u3055\u308c\u305f\u6a5f\u80fd\u306e\u4e00\u90e8\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><pre title=\"ConcurrentHashMapExample3.java\">\r\npackage jp.yucchi.concurrenthashmapexample3;\r\n\r\nimport java.lang.management.ManagementFactory;\r\nimport java.util.concurrent.ConcurrentHashMap;\r\nimport java.util.concurrent.ForkJoinPool;\r\n\r\n\/**\r\n *\r\n * @author Yucchi\r\n *\/\r\npublic class ConcurrentHashMapExample3 {\r\n\r\n    public static void main(String[] args) {\r\n\r\n        \/\/ CPU\r\n        System.out.println(\"CPU: \" + ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors());\r\n        \/\/ -Djava.util.concurrent.ForkJoinPool.common.parallelism=7\r\n        System.out.println(\"ForkJoinPoolParallelism: \" + ForkJoinPool.getCommonPoolParallelism() + System.getProperty(\"line.separator\"));\r\n\r\n        ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();\r\n        map.put(\"JDK 1.1.4\", \"Sparkler\");\r\n        map.put(\"JDK 1.1.5\", \"Pumpkin\");\r\n        map.put(\"JDK 1.1.6\", \"Abigail\");\r\n        map.put(\"JDK 1.1.7\", \"Brutus\");\r\n        map.put(\"JDK 1.1.8\", \"Chelsea\");\r\n        map.put(\"J2SE 1.2\", \"Playground\");\r\n        map.put(\"J2SE 1.2.1\", \"null\");\r\n        map.put(\"J2SE 1.2.2\", \"Cricket\");\r\n        map.put(\"J2SE 1.3\", \"Kestrel\");\r\n        map.put(\"J2SE 1.3.1\", \"Ladybird\");\r\n        map.put(\"J2SE 1.4\", \"Merlin\");\r\n        map.put(\"J2SE 1.4.1\", \"Hopper\");\r\n        map.put(\"J2SE 1.4.2\", \"Mantis\");\r\n        map.put(\"J2SE 5.0\", \"Tiger\");\r\n        map.put(\"Java SE 6\", \"Mustang\");\r\n        map.put(\"Java SE 7\", \"Dolphin\");\r\n        map.put(\"Java SE 8\", \"null\");\r\n        map.put(\"Java SE 9\", \"\");\r\n\r\n        System.out.println(\"\u30de\u30c3\u30d4\u30f3\u30b0\u6570: \" + map.mappingCount()\r\n                + System.getProperty(\"line.separator\"));\r\n\r\n        System.out.println(\"(\u25cb\uff65\u03c9\uff65)\uff89------------- forEach (BiConsumer) -------------\");\r\n        map.forEach(1,\r\n                (key, value) -> System.out.println(Thread.currentThread().getName() + \": \" + key + \" = \" + value));\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- forEach (BiFunction, Consumer) -------------\");\r\n        map.forEach(1,\r\n                (key, value) -> key.length() > 7 && value.length() > 7 ? Thread.currentThread().getName() + \": \" + key + \" = \" + value : null,\r\n                System.out::println);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- forEachEntry (Function Consumer)-------------\");\r\n        map.forEachEntry(1,\r\n                entry -> entry.getKey().length() > 7 && entry.getValue().length() > 7 ? Thread.currentThread().getName() + \": \" + entry.getKey() + \" = \" + entry.getValue() : null,\r\n                System.out::println);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- search -------------\");\r\n        String searchResult = map.search(1, (key, value) -> key.length() > 7 && value.length() > 7 ? key + \" = \" + value : null);\r\n        System.out.println(\"searchResult: \" + searchResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- searchKeys -------------\");\r\n        String searchKeysResult = map.searchKeys(1, key -> key.length() > 7 ? key : null);\r\n        System.out.println(\"searchKeysResult: \" + searchKeysResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- searchValues -------------\");\r\n        String searchValuesResult = map.searchValues(1, value -> value.length() > 7 ? value : null);\r\n        System.out.println(\"searchValuesResult: \" + searchValuesResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- searchEntries -------------\");\r\n        String searchEntriesResult = map.searchEntries(1,\r\n                entry -> entry.getKey().length() > 7 && entry.getValue().length() > 7 ? entry.getKey() + \" = \" + entry.getValue() : null);\r\n        System.out.println(\"searchEntriesResult: \" + searchEntriesResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- reduce -------------\");\r\n        String reduceResult = map.reduce(1,\r\n                (key, value) -> key + \" = \" + value,\r\n                (s1, s2) -> s1 + System.getProperty(\"line.separator\") + s2);\r\n        System.out.println(\"reduceResult\" + System.getProperty(\"line.separator\") + reduceResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceKeys -------------\");\r\n        String reduceKeysResult = map.reduceKeys(1,\r\n                key -> key.length() > 9 ? key : null,\r\n                (s1, s2) -> s1 + System.getProperty(\"line.separator\") + s2);\r\n        System.out.println(\"reduceKeysResult\" + System.getProperty(\"line.separator\") + reduceKeysResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceValues -------------\");\r\n        String reduceValuesResult = map.reduceValues(1,\r\n                value -> value.length() > 4 && value.length() < 7 ? value : null,\r\n                (s1, s2) -> s1 + System.getProperty(\"line.separator\") + s2);\r\n        System.out.println(\"reduceValuesResult\" + System.getProperty(\"line.separator\") + reduceValuesResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceEntries -------------\");\r\n        String reduceEntriesResult = map.reduceEntries(1,\r\n                entry -> entry.getKey().length() > 7 && entry.getValue().length() > 7 ? entry.getKey() + \" = \" + entry.getValue() : null,\r\n                (s1, s2) -> s1 + System.getProperty(\"line.separator\") + s2);\r\n        System.out.println(\"reduceEntriesResult\" + System.getProperty(\"line.separator\") + reduceEntriesResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceMaxValuesResult -------------\");\r\n        int reduceMaxValuesResult = map.reduceValuesToInt(1,\r\n                String::length,\r\n                0,\r\n                Integer::max);\r\n        System.out.println(reduceMaxValuesResult);\r\n\r\n        System.out.println(System.getProperty(\"line.separator\")\r\n                + \"(\u25cb\uff65\u03c9\uff65)\uff89------------- \u304a\u7d42\u3044\uff01 -------------\");\r\n    }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>CPU: 32<br \/>ForkJoinPoolParallelism: 7<\/p>\n<p>\u30de\u30c3\u30d4\u30f3\u30b0\u6570: 18<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- forEach (BiConsumer) -------------<br \/>main: JDK 1.1.7 = Brutus<br \/>main: Java SE 9 = <br \/>main: JDK 1.1.8 = Chelsea<br \/>main: Java SE 8 = null<br \/>main: JDK 1.1.5 = Pumpkin<br \/>main: JDK 1.1.6 = Abigail<br \/>main: J2SE 1.2 = Playground<br \/>main: JDK 1.1.4 = Sparkler<br \/>ForkJoinPool.commonPool-worker-3: J2SE 1.2.2 = Cricket<br \/>main: Java SE 7 = Dolphin<br \/>ForkJoinPool.commonPool-worker-3: J2SE 1.3.1 = Ladybird<br \/>ForkJoinPool.commonPool-worker-4: J2SE 1.4 = Merlin<br \/>ForkJoinPool.commonPool-worker-1: J2SE 1.4.2 = Mantis<br \/>ForkJoinPool.commonPool-worker-2: J2SE 1.3 = Kestrel<br \/>main: Java SE 6 = Mustang<br \/>ForkJoinPool.commonPool-worker-5: J2SE 1.4.1 = Hopper<br \/>ForkJoinPool.commonPool-worker-4: J2SE 5.0 = Tiger<br \/>ForkJoinPool.commonPool-worker-3: J2SE 1.2.1 = null<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- forEach (BiFunction, Consumer) -------------<br \/>ForkJoinPool.commonPool-worker-5: J2SE 1.3.1 = Ladybird<br \/>main: J2SE 1.2 = Playground<br \/>ForkJoinPool.commonPool-worker-1: JDK 1.1.4 = Sparkler<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- forEachEntry (Function Consumer)-------------<br \/>ForkJoinPool.commonPool-worker-1: J2SE 1.3.1 = Ladybird<br \/>ForkJoinPool.commonPool-worker-6: JDK 1.1.4 = Sparkler<br \/>ForkJoinPool.commonPool-worker-7: J2SE 1.2 = Playground<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- search -------------<br \/>searchResult: J2SE 1.3.1 = Ladybird<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- searchKeys -------------<br \/>searchKeysResult: J2SE 1.2.2<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- searchValues -------------<br \/>searchValuesResult: Sparkler<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- searchEntries -------------<br \/>searchEntriesResult: JDK 1.1.4 = Sparkler<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduce -------------<br \/>reduceResult<br \/>JDK 1.1.7 = Brutus<br \/>Java SE 9 = <br \/>JDK 1.1.8 = Chelsea<br \/>Java SE 8 = null<br \/>JDK 1.1.5 = Pumpkin<br \/>JDK 1.1.6 = Abigail<br \/>J2SE 1.2 = Playground<br \/>JDK 1.1.4 = Sparkler<br \/>Java SE 7 = Dolphin<br \/>Java SE 6 = Mustang<br \/>J2SE 1.2.2 = Cricket<br \/>J2SE 1.3.1 = Ladybird<br \/>J2SE 1.2.1 = null<br \/>J2SE 1.3 = Kestrel<br \/>J2SE 1.4 = Merlin<br \/>J2SE 5.0 = Tiger<br \/>J2SE 1.4.2 = Mantis<br \/>J2SE 1.4.1 = Hopper<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceKeys -------------<br \/>reduceKeysResult<br \/>J2SE 1.2.2<br \/>J2SE 1.3.1<br \/>J2SE 1.2.1<br \/>J2SE 1.4.2<br \/>J2SE 1.4.1<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceValues -------------<br \/>reduceValuesResult<br \/>Brutus<br \/>Merlin<br \/>Tiger<br \/>Mantis<br \/>Hopper<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceEntries -------------<br \/>reduceEntriesResult<br \/>J2SE 1.2 = Playground<br \/>JDK 1.1.4 = Sparkler<br \/>J2SE 1.3.1 = Ladybird<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceMaxValuesResult -------------<br \/>10<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- \u304a\u7d42\u3044\uff01 -------------<\/p>\n<p>&nbsp;<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u3056\u3063\u304f\u308a\u8ffd\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>16 \u884c\u76ee\u3067\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u8ad6\u7406 CPU \u6570\u3092\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001VM \u30aa\u30d7\u30b7\u30e7\u30f3\u3092 -Djava.util.concurrent.ForkJoinPool.common.parallelism=7 \u3068\u3057\u3066\u3042\u308b\u306e\u3067\u6b63\u3057\u304f\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3092 18 \u884c\u76ee\u306e\u30b3\u30fc\u30c9\u3067\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">\/\/ CPU<br \/>System.out.println(\"CPU: \" + ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors());<br \/>\/\/ -Djava.util.concurrent.ForkJoinPool.common.parallelism=7<br \/>System.out.println(\"ForkJoinPoolParallelism: \" + ForkJoinPool.getCommonPoolParallelism() + System.getProperty(\"line.separator\"));<br \/><\/font><\/p>\n<\/blockquote>\n<p><a href=\"http:\/\/yucchi.jp\/blog\/wp-content\/uploads\/2015\/06\/1.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"1\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"1\" src=\"http:\/\/yucchi.jp\/blog\/wp-content\/uploads\/2015\/06\/1_thumb.png\" width=\"904\" height=\"411\"><\/a><\/p>\n<p>20 \u884c\u76ee\u304b\u3089 38 \u884c\u76ee\u306b\u304b\u3051\u3066\u3001ConcurrentHashMap \u3092\u751f\u6210\u3057\u3066\u30c7\u30fc\u30bf\u3092\u633f\u5165\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">ConcurrentHashMap&lt;String, String&gt; map = new ConcurrentHashMap&lt;&gt;();<br \/>map.put(\"JDK 1.1.4\", \"Sparkler\");<br \/>.<br \/>.<br \/>map.put(\"Java SE 9\", \"\");<\/font><\/p>\n<\/blockquote>\n<p>40 \u884c\u76ee\u3067\u30de\u30c3\u30d4\u30f3\u30b0\u6570\u3092\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">System.out.println(\"\u30de\u30c3\u30d4\u30f3\u30b0\u6570: \" + map.mappingCount()<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + System.getProperty(\"line.separator\"));<\/font><\/p>\n<\/blockquote>\n<p>public long mappingCount() \u306f\u3001API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3088\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><font color=\"#666666\">\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002ConcurrentHashMap\u306b\u306fint\u3067\u8868\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u6570\u3088\u308a\u591a\u304f\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u305f\u3081\u3001<\/font><\/p>\n<p><font color=\"#666666\">size()\u306e\u304b\u308f\u308a\u306b\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u8fd4\u3055\u308c\u308b\u5024\u306f\u63a8\u5b9a\u5024\u3067\u3042\u308a\u3001\u633f\u5165\u3084\u524a\u9664\u304c\u540c\u6642\u306b\u884c\u308f\u308c\u305f\u5834\u5408\u3001\u5b9f\u969b\u306e\u30ab\u30a6\u30f3\u30c8\u306f\u7570\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/font><\/p>\n<p>\u5927\u304d\u306a\u8981\u7d20\u3092\u6301\u3064\u5834\u5408\u306f size() \u306e\u4ee3\u308f\u308a\u306b mappingCount() \u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3088\u3046\u3067\u3059\u306d\u3002<\/p>\n<p><strong><font color=\"#0000ff\" size=\"5\">forEach<\/font><\/strong><\/p>\n<p>43 \u884c\u76ee\u304b\u3089 57 \u884c\u76ee\u307e\u3067\u306f forEach \u3092\u8a66\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>forEach \u306f\u6b21\u306e\u3088\u3046\u306b 9 \u7a2e\u985e\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5f15\u6570\u306b Function, BiFunction \u306e\u3088\u3046\u306a\u95a2\u6570\u3092\u542b\u3080\u3082\u306e\u3082\u3042\u308a\u4fbf\u5229\u306b\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">public void forEach(BiConsumer&lt;? super K,? super V&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public void forEach(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiConsumer&lt;? super K,? super V&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public &lt;U&gt; void forEach(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super K,? super V,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super U&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public void forEachKey(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super K&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public &lt;U&gt; void forEachKey(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;? super K,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super U&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public void forEachValue(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super V&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public &lt;U&gt; void forEachValue(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;? super V,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super U&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public void forEachEntry(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super Map.Entry&lt;K,V&gt;&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">public &lt;U&gt; void forEachEntry(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;Map.Entry&lt;K,V&gt;,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super U&gt; action)<\/font><\/p>\n<\/blockquote>\n<p>\u4eca\u56de\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u3001<\/p>\n<p>public void forEach(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiConsumer&lt;? super K,? super V&gt; action)<\/p>\n<p>public &lt;U&gt; void forEach(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super K,? super V,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super U&gt; action)<\/p>\n<p>public &lt;U&gt; void forEachEntry(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;Map.Entry&lt;K,V&gt;,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super U&gt; action)<\/p>\n<p>\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u7b2c\u4e00\u5f15\u6570\u306e parallelismThreshold \u306f\u3001\u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3044\u308f\u3086\u308b\u95be\u5024\u3067\u3059\u3002<\/p>\n<p>\u4e26\u884c\u51e6\u7406\u3092\u3059\u308b\u305f\u3081\u306b\u7b2c\u4e00\u5f15\u6570\u306e parallelismThreshold \u3092 1 \u3068\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u672c\u5f53\u306b\u4e26\u884c\u51e6\u7406\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u306e\u305f\u3081\u306b\u30b9\u30ec\u30c3\u30c9\u540d\u3092\u8868\u793a\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u6ce8\u610f\u304c\u3044\u308b\u306e\u306f\u3001public void forEach(BiConsumer&lt;? super K,? super V&gt; action)\u3000\u3067\u3059\u306d\u3002<\/p>\n<p>\u3053\u308c\u3001\u5f15\u6570\u306b parallelismThreshold \u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u4e26\u884c\u51e6\u7406\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u6b8b\u308a\u306e\u5f15\u6570\u306f Java SE 8 \u3067\u306f\u304a\u99b4\u67d3\u307f\u306e\u95a2\u6570\u3067\u3059\u304b\u3089\u7279\u306b\u8aac\u660e\u3059\u308b\u3053\u3068\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u4e00\u3064\u3060\u3051 API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u5185\u5bb9\u3092\u7d39\u4ecb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; void forEach(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super K,? super V,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Consumer&lt;? super U&gt; action)<\/font><\/p>\n<p><font color=\"#666666\">\u5404(\u30ad\u30fc, \u5024)\u306enull\u3067\u306a\u3044\u5404\u5909\u63db\u306b\u5bfe\u3057\u3001\u6307\u5b9a\u3055\u308c\u305f\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/><\/font><font color=\"#666666\">U - \u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u306e\u623b\u308a\u5024\u306e\u578b<\/p>\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>transformer - \u8981\u7d20\u306e\u5909\u63db\u3092\u8fd4\u3059\u95a2\u6570\u3002\u5909\u63db\u304c\u306a\u3044\u5834\u5408\u306fnull(\u305d\u306e\u5834\u5408\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u306f\u9069\u7528\u3055\u308c\u306a\u3044)<br \/>action - \u30a2\u30af\u30b7\u30e7\u30f3<\/font><\/p>\n<\/blockquote>\n<p>\u500b\u4eba\u7684\u306b\u306f\u3053\u308c\u304c\u4e00\u756a\u4f7f\u3044\u52dd\u624b\u304c\u826f\u3044\u304b\u306a\u3063\u3066\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u4e09\u3064\u306e forEach \u306e\u5b9f\u884c\u7d50\u679c\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p>\u306f\u3058\u3081\u306b\u7b2c\u4e8c\u5f15\u6570\u306b BiConsumer \u3092\u6301\u3064 forEach \u306e\u51e6\u7406\u3067\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">map.forEach(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (key, value) -&gt; System.out.println(Thread.currentThread().getName() + \": \" + key + \" = \" + value));<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u623b\u308a\u5024\u7121\u3057\u306e\u51e6\u7406\u3067\u30b9\u30ec\u30c3\u30c9\u540d\u3068 key, value \u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u3068\u3057\u307e\u3059\u3002\uff08\u89e3\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u9023\u7d50\u7528\u306e\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- forEach (BiConsumer) -------------<br \/>main: JDK 1.1.7 = Brutus<br \/>main: Java SE 9 = <br \/>main: JDK 1.1.8 = Chelsea<br \/>main: Java SE 8 = null<br \/>main: JDK 1.1.5 = Pumpkin<br \/>main: JDK 1.1.6 = Abigail<br \/>main: J2SE 1.2 = Playground<br \/>main: JDK 1.1.4 = Sparkler<br \/>ForkJoinPool.commonPool-worker-3: J2SE 1.2.2 = Cricket<br \/>main: Java SE 7 = Dolphin<br \/>ForkJoinPool.commonPool-worker-3: J2SE 1.3.1 = Ladybird<br \/>ForkJoinPool.commonPool-worker-4: J2SE 1.4 = Merlin<br \/>ForkJoinPool.commonPool-worker-1: J2SE 1.4.2 = Mantis<br \/>ForkJoinPool.commonPool-worker-2: J2SE 1.3 = Kestrel<br \/>main: Java SE 6 = Mustang<br \/>ForkJoinPool.commonPool-worker-5: J2SE 1.4.1 = Hopper<br \/>ForkJoinPool.commonPool-worker-4: J2SE 5.0 = Tiger<br \/>ForkJoinPool.commonPool-worker-3: J2SE 1.2.1 = null<\/p>\n<p>&nbsp;<\/p>\n<p>\u6b21\u306f\u3001\u5f15\u6570\u304c\u4e09\u3064\u306e forEach \u3067\u7b2c\u4e8c\u5f15\u6570\u306b BiFunction \u3092\u7b2c\u4e09\u5f15\u6570\u306b Consumer \u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">map.forEach(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (key, value) -&gt; key.length() &gt; 7 &amp;&amp; value.length() &gt; 7 ? Thread.currentThread().getName() + \": \" + key + \" = \" + value : null,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out::println);<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u7b2c\u4e8c\u5f15\u6570\u306e BiFunction \u3067 key \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u304f\u304b\u3064 value \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001\u30b9\u30ec\u30c3\u30c9\u540d\u3068 key, value \u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u89e3\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u9023\u7d50\u7528\u306e\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e Consumer \u3067\u306f\u305d\u308c\u3089\u3092\u6a19\u6e96\u51fa\u529b\u306b\u8868\u793a\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- forEach (BiFunction, Consumer) -------------<br \/>ForkJoinPool.commonPool-worker-5: J2SE 1.3.1 = Ladybird<br \/>main: J2SE 1.2 = Playground<br \/>ForkJoinPool.commonPool-worker-1: JDK 1.1.4 = Sparkler<\/p>\n<p>&nbsp;<\/p>\n<p>\u6b21\u306e forEach \u306f\u3001forEachEntry \u3067 Map.Entry \u306b\u64cd\u4f5c\u3092\u52a0\u3048\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">map.forEachEntry(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry -&gt; entry.getKey().length() &gt; 7 &amp;&amp; entry.getValue().length() &gt; 7 ? Thread.currentThread().getName() + \": \" + entry.getKey() + \" = \" + entry.getValue() : null,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out::println);<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u7b2c\u4e8c\u5f15\u6570\u306e Function \u3067\u3001Entry \u306e key \u3068 value \u3092\u305d\u308c\u305e\u308c\u53d6\u5f97\u3001\u305d\u3057\u3066 key \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u304f\u304b\u3064 value \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001\u30b9\u30ec\u30c3\u30c9\u540d\u3068 key, value \u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u89e3\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u9023\u7d50\u7528\u306e\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e Consumer \u3067\u3067\u306f\u305d\u308c\u3089\u3092\u6a19\u6e96\u51fa\u529b\u306b\u8868\u793a\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- forEachEntry (Function Consumer)-------------<br \/>ForkJoinPool.commonPool-worker-1: J2SE 1.3.1 = Ladybird<br \/>ForkJoinPool.commonPool-worker-6: JDK 1.1.4 = Sparkler<br \/>ForkJoinPool.commonPool-worker-7: J2SE 1.2 = Playground<\/p>\n<p>forEach \u3060\u3051\u3067\u3082\u81f3\u308c\u308a\u5c3d\u304f\u305b\u308a\u3067\u4fbf\u5229\u306b\u4f7f\u3048\u307e\u3059\u306d\u3002(^_^)<\/p>\n<p>Function, BiFunction \u304c\u4f7f\u3048\u308b\u306e\u3063\u3066\u5e78\u305b\u3067\u3059\uff01<\/p>\n<p><strong><font color=\"#0000ff\" size=\"5\">search<\/font><\/strong><\/p>\n<p>\u305d\u308c\u3067\u306f search \u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>59 \u884c\u76ee\u304b\u3089 78 \u884c\u76ee\u307e\u3067&nbsp; search \u3092\u8a66\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>search \u306f 4 \u7a2e\u985e\u306e\u512a\u308c\u305f\u30e1\u30bd\u30c3\u30c9\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u305e\u308c API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u5185\u5bb9\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U search(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super K,? super V,? extends U&gt; searchFunction)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u5404(\u30ad\u30fc\u3001\u5024)\u306b\u9069\u7528\u3057\u3001null\u3067\u306a\u3044\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059(\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306fnull)\u3002<br \/>\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u5f8c\u306e\u8981\u7d20\u306e\u51e6\u7406\u306f\u6291\u5236\u3055\u308c\u3001\u691c\u7d22\u95a2\u6570\u306e\u4ed6\u306e\u4e26\u5217\u547c\u51fa\u3057\u306e\u7d50\u679c\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u691c\u7d22\u95a2\u6570\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>searchFunction - \u6210\u529f\u3057\u305f\u5834\u5408\u306fnull\u4ee5\u5916\u306e\u7d50\u679c\u3092\u8fd4\u3057\u3001\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306fnull\u3092\u8fd4\u3059\u95a2\u6570\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u5404(\u30ad\u30fc\u3001\u5024)\u306b\u5bfe\u3057\u3066\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u9069\u7528\u3057\u305f\u5834\u5408\u306enull\u4ee5\u5916\u306e\u7d50\u679c\u3002\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306fnull<\/font><\/p>\n<p><font color=\"#666666\"><\/font>&nbsp;<\/p>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U searchKeys(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;? super K,? extends U&gt; searchFunction)<\/font><\/p>\n<p><font color=\"#666666\">\u5404\u30ad\u30fc\u306b\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u9069\u7528\u3057\u305fnull\u4ee5\u5916\u306e\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002\u7d50\u679c\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u5f8c\u306e\u8981\u7d20\u306e\u51e6\u7406\u306f\u6291\u5236\u3055\u308c\u3001\u691c\u7d22\u95a2\u6570\u306e\u4ed6\u306e\u4e26\u5217\u547c\u51fa\u3057\u306e\u7d50\u679c\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u691c\u7d22\u95a2\u6570\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>searchFunction - \u6210\u529f\u3057\u305f\u5834\u5408\u306fnull\u4ee5\u5916\u306e\u7d50\u679c\u3092\u8fd4\u3057\u3001\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306fnull\u3092\u8fd4\u3059\u95a2\u6570\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u5404\u30ad\u30fc\u306b\u5bfe\u3057\u3066\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u9069\u7528\u3057\u305f\u5834\u5408\u306enull\u4ee5\u5916\u306e\u7d50\u679c\u3002\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306fnull<\/font><\/p>\n<p><font color=\"#666666\"><\/font>&nbsp;<\/p>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U searchValues(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;? super V,? extends U&gt; searchFunction)<\/font><\/p>\n<p><font color=\"#666666\">\u5404\u5024\u306b\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u9069\u7528\u3057\u305fnull\u4ee5\u5916\u306e\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002\u7d50\u679c\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u5f8c\u306e\u8981\u7d20\u306e\u51e6\u7406\u306f\u6291\u5236\u3055\u308c\u3001\u691c\u7d22\u95a2\u6570\u306e\u4ed6\u306e\u4e26\u5217\u547c\u51fa\u3057\u306e\u7d50\u679c\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002<br \/><\/font><br \/><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u691c\u7d22\u95a2\u6570\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>searchFunction - \u6210\u529f\u3057\u305f\u5834\u5408\u306fnull\u4ee5\u5916\u306e\u7d50\u679c\u3092\u8fd4\u3057\u3001\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306fnull\u3092\u8fd4\u3059\u95a2\u6570\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u5404\u5024\u306b\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u9069\u7528\u3057\u305fnull\u4ee5\u5916\u306e\u7d50\u679c\u3002\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306fnull<\/font><\/p>\n<p><font color=\"#666666\"><\/font>&nbsp;<\/p>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U searchEntries(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;Map.Entry&lt;K,V&gt;,? extends U&gt; searchFunction)<\/font><\/p>\n<p><font color=\"#666666\">\u5404\u30a8\u30f3\u30c8\u30ea\u306b\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u9069\u7528\u3057\u305fnull\u4ee5\u5916\u306e\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002\u7d50\u679c\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u5f8c\u306e\u8981\u7d20\u306e\u51e6\u7406\u306f\u6291\u5236\u3055\u308c\u3001\u691c\u7d22\u95a2\u6570\u306e\u4ed6\u306e\u4e26\u5217\u547c\u51fa\u3057\u306e\u7d50\u679c\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002<br \/><\/font><br \/><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u691c\u7d22\u95a2\u6570\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>searchFunction - \u6210\u529f\u3057\u305f\u5834\u5408\u306fnull\u4ee5\u5916\u306e\u7d50\u679c\u3092\u8fd4\u3057\u3001\u305d\u308c\u4ee5\u5916\u306e\u5834\u5408\u306fnull\u3092\u8fd4\u3059\u95a2\u6570\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u5404\u30a8\u30f3\u30c8\u30ea\u306b\u6307\u5b9a\u3055\u308c\u305f\u691c\u7d22\u95a2\u6570\u3092\u9069\u7528\u3057\u305fnull\u4ee5\u5916\u306e\u7d50\u679c\u3002\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306fnull<\/font><\/p>\n<\/blockquote>\n<p>API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u898b\u308b\u3068\u305d\u308c\u305e\u308c key \u3068 value \u306b\u5bfe\u3059\u308b\u64cd\u4f5c\u3001key \u306b\u5bfe\u3059\u308b\u64cd\u4f5c\u3001value \u306b\u5bfe\u3059\u308b\u64cd\u4f5c\u3001Map.Entry \u306b\u5bfe\u3059\u308b\u64cd\u4f5c\u3092\u884c\u3046\u3088\u3046\u306b\u5206\u3051\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>search \u3067\u3082 Function, BiFunction \u304c\u4fbf\u5229\u306b\u691c\u7d22\u95a2\u6570\u3068\u3057\u3066\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u9806\u756a\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u51e6\u7406\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>key \u3068 value \u306b\u3088\u308b\u691c\u7d22<\/strong><\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color=\"#666666\">String searchResult = map.search(1, (key, value) -&gt; key.length() &gt; 7 &amp;&amp; value.length() &gt; 7 ? key + \" = \" + value : null);<\/font><\/p>\n<p>key \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u304f\u304b\u3064 value \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001key, value \u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u89e3\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u9023\u7d50\u7528\u306e\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- search -------------<br \/>searchResult: J2SE 1.3.1 = Ladybird<\/p>\n<p>API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3088\u308c\u3070\u3001\u8907\u6570\u691c\u7d22\u6761\u4ef6\u306b\u8a72\u5f53\u3059\u308b\u5834\u5408\u3001\u6700\u521d\u306b\u691c\u7d22\u306b\u6210\u529f\u3057\u305f\u4e00\u3064\u3060\u3051\u304c\u9078\u629e\u3055\u308c\u3001\u4ed6\u306f\u7834\u68c4\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3088\u3063\u3066\u691c\u7d22\u6761\u4ef6\u306b\u8a72\u5f53\u3059\u308b\u3082\u306e\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u5fc5\u305a\u7d50\u679c\u304c\u540c\u3058\u306b\u306a\u308b\u3068\u306f\u9650\u3089\u306a\u3044\u3002<\/p>\n<p><strong>key \u306b\u3088\u308b\u691c\u7d22<\/strong><\/p>\n<blockquote>\n<p><font color=\"#666666\">String searchKeysResult = map.searchKeys(1, key -&gt; key.length() &gt; 7 ? key : null);<\/font><\/p>\n<\/blockquote>\n<p>key \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001key \u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- searchKeys -------------<br \/>searchKeysResult: J2SE 1.2.2<\/p>\n<p><strong>value \u306b\u3088\u308b\u691c\u7d22<\/strong><\/p>\n<blockquote>\n<p><font color=\"#666666\">String searchValuesResult = map.searchValues(1, value -&gt; value.length() &gt; 7 ? value : null);<\/font><\/p>\n<\/blockquote>\n<p>value \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001value \u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- searchValues -------------<br \/>searchValuesResult: Sparkler<\/p>\n<p><strong>Map.Entry \u306b\u3088\u308b\u691c\u7d22<\/strong><\/p>\n<blockquote>\n<p><font color=\"#666666\">String searchEntriesResult = map.searchEntries(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry -&gt; entry.getKey().length() &gt; 7 &amp;&amp; entry.getValue().length() &gt; 7 ? entry.getKey() + \" = \" + entry.getValue() : null);<\/font><\/p>\n<\/blockquote>\n<p>Entry \u306e key \u3068 value \u3092\u305d\u308c\u305e\u308c\u53d6\u5f97\u3001\u305d\u3057\u3066 key \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u304f\u304b\u3064 value \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001key, value \u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u89e3\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u9023\u7d50\u7528\u306e\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- searchEntries -------------<br \/>searchEntriesResult: JDK 1.1.4 = Sparkler<\/p>\n<p><strong><font color=\"#0000ff\" size=\"5\">reduce<\/font><\/strong><\/p>\n<p>\u305d\u308c\u3067\u306f reduce \u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>80 \u884c\u76ee\u304b\u3089 114 \u884c\u76ee\u307e\u3067 reduce \u3092\u8a66\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>reduce \u3082 search \u540c\u69d8\u306b key \u3068 value, key, value, Map.Entry \u305d\u308c\u305e\u308c\u306b\u64cd\u4f5c\u3092\u884c\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U reduce(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super K,? super V,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super U,? super U,? extends U&gt; reducer)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30c7\u30e5\u30fc\u30b5\u3092\u4f7f\u7528\u3057\u3066\u5024\u3092\u7d50\u5408\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u3059\u3079\u3066\u306e(\u30ad\u30fc\u3001\u5024)\u30da\u30a2\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u306e\u7d2f\u7a4d\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002\u7d50\u679c\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>transformer - \u8981\u7d20\u306e\u5909\u63db\u3092\u8fd4\u3059\u95a2\u6570\u3002\u5909\u63db\u304c\u306a\u3044\u5834\u5408\u306fnull(\u305d\u306e\u5834\u5408\u3001\u5024\u306f\u7d50\u5408\u3055\u308c\u306a\u3044)<br \/>reducer - \u4ea4\u63db\u53ef\u80fd\u6027\u3068\u7d50\u5408\u6027\u3092\u6301\u3064\u7d50\u5408\u95a2\u6570<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u3059\u3079\u3066\u306e(\u30ad\u30fc\u3001\u5024)\u30da\u30a2\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u3092\u7d2f\u7a4d\u3057\u305f\u7d50\u679c<\/font><\/p>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U reduceKeys(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;? super K,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super U,? super U,? extends U&gt; reducer)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30c7\u30e5\u30fc\u30b5\u3092\u4f7f\u7528\u3057\u3066\u5024\u3092\u7d50\u5408\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u3059\u3079\u3066\u306e\u30ad\u30fc\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u306e\u7d2f\u7a4d\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002\u7d50\u679c\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>transformer - \u8981\u7d20\u306e\u5909\u63db\u3092\u8fd4\u3059\u95a2\u6570\u3002\u5909\u63db\u304c\u306a\u3044\u5834\u5408\u306fnull(\u305d\u306e\u5834\u5408\u3001\u5024\u306f\u7d50\u5408\u3055\u308c\u306a\u3044)<br \/>reducer - \u4ea4\u63db\u53ef\u80fd\u6027\u3068\u7d50\u5408\u6027\u3092\u6301\u3064\u7d50\u5408\u95a2\u6570<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u3059\u3079\u3066\u306e\u30ad\u30fc\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u3092\u7d2f\u7a4d\u3057\u305f\u7d50\u679c<\/font><\/p>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U reduceValues(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;? super V,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super U,? super U,? extends U&gt; reducer)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30c7\u30e5\u30fc\u30b5\u3092\u4f7f\u7528\u3057\u3066\u5024\u3092\u7d50\u5408\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u3059\u3079\u3066\u306e\u5024\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u306e\u7d2f\u7a4d\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002\u7d50\u679c\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>transformer - \u8981\u7d20\u306e\u5909\u63db\u3092\u8fd4\u3059\u95a2\u6570\u3002\u5909\u63db\u304c\u306a\u3044\u5834\u5408\u306fnull(\u305d\u306e\u5834\u5408\u3001\u5024\u306f\u7d50\u5408\u3055\u308c\u306a\u3044)<br \/>reducer - \u4ea4\u63db\u53ef\u80fd\u6027\u3068\u7d50\u5408\u6027\u3092\u6301\u3064\u7d50\u5408\u95a2\u6570<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u3059\u3079\u3066\u306e\u5024\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u3092\u7d2f\u7a4d\u3057\u305f\u7d50\u679c<\/font><\/p>\n<p><font color=\"#666666\" size=\"3\">public &lt;U&gt; U reduceEntries(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Function&lt;Map.Entry&lt;K,V&gt;,? extends U&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BiFunction&lt;? super U,? super U,? extends U&gt; reducer)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30c7\u30e5\u30fc\u30b5\u3092\u4f7f\u7528\u3057\u3066\u5024\u3092\u7d50\u5408\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u3059\u3079\u3066\u306e\u30a8\u30f3\u30c8\u30ea\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u306e\u7d2f\u7a4d\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002\u7d50\u679c\u304c\u306a\u3044\u5834\u5408\u306fnull\u3092\u8fd4\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>U - \u30c8\u30e9\u30f3\u30b9\u30d5\u30a9\u30fc\u30de\u306e\u623b\u308a\u5024\u306e\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>transformer - \u8981\u7d20\u306e\u5909\u63db\u3092\u8fd4\u3059\u95a2\u6570\u3002\u5909\u63db\u304c\u306a\u3044\u5834\u5408\u306fnull(\u305d\u306e\u5834\u5408\u3001\u5024\u306f\u7d50\u5408\u3055\u308c\u306a\u3044)<br \/>reducer - \u4ea4\u63db\u53ef\u80fd\u6027\u3068\u7d50\u5408\u6027\u3092\u6301\u3064\u7d50\u5408\u95a2\u6570<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u3059\u3079\u3066\u306e\u30a8\u30f3\u30c8\u30ea\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u3092\u7d2f\u7a4d\u3057\u305f\u7d50\u679c<\/font><\/p>\n<\/blockquote>\n<p>reduce \u306f\u3001int, long, double \u306a\u3069\u3092\u4fbf\u5229\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b reduce\u25cb\u25b3\u00d7\u25a1ToInt, reduce\u25cb\u25b3\u00d7\u25a1ToLong, reduce\u25cb\u25b3\u00d7\u25a1ToDouble \u306a\u3069\u3082\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306f\u3001\u5165\u529b\u3092<em>\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b\u306b\u5909\u63db\u3057\u3066\u57fa\u6e96\u5024\u3092\u6307\u5b9a\u3057\u3066\u7d2f\u7a4d\u8a08\u7b97\u3057\u3066\u5024\u3092\u8fd4\u3059\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/em><\/p>\n<p><em>\u4eca\u56de\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u306f\u3001<\/em>reduceValuesToInt \u3060\u3051\u8a66\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3067\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\" size=\"3\">public int reduceValuesToInt(long parallelismThreshold,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ToIntFunction&lt;? super V&gt; transformer,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int basis,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IntBinaryOperator reducer)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u30ea\u30c7\u30e5\u30fc\u30b5\u3092\u4f7f\u7528\u3057\u3066\u5024\u3092\u7d50\u5408\u3057\u3001\u6307\u5b9a\u3055\u308c\u305f\u57fa\u6e96\u3092\u8b58\u5225\u5024\u3068\u3057\u3066\u4f7f\u7528\u3057\u3066\u3001\u3059\u3079\u3066\u306e\u5024\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u306e\u7d2f\u7a4d\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>parallelismThreshold - \u3053\u306e\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4e26\u5217\u7684\u306b\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a(\u63a8\u5b9a\u306e)\u8981\u7d20\u6570<br \/>transformer - \u8981\u7d20\u306e\u5909\u63db\u3092\u8fd4\u3059\u95a2\u6570basis - \u30ea\u30c0\u30af\u30b7\u30e7\u30f3\u306e\u8b58\u5225(\u521d\u671f\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024)<br \/>reducer - \u4ea4\u63db\u53ef\u80fd\u6027\u3068\u7d50\u5408\u6027\u3092\u6301\u3064\u7d50\u5408\u95a2\u6570<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:\u3059\u3079\u3066\u306e\u5024\u306e\u6307\u5b9a\u3055\u308c\u305f\u5909\u63db\u3092\u7d2f\u7a4d\u3057\u305f\u7d50\u679c<\/font><\/p>\n<\/blockquote>\n<p>\u305d\u308c\u3067\u306f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>key \u3068 value \u306b\u3088\u308b\u30ea\u30c7\u30e5\u30fc\u30b9<\/strong><\/p>\n<blockquote>\n<p><font color=\"#666666\">String reduceResult = map.reduce(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (key, value) -&gt; key + \" = \" + value,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (s1, s2) -&gt; s1 + System.getProperty(\"line.separator\") + s2);<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u7b2c\u4e8c\u5f15\u6570\u306e BiFunction \u3067\u8981\u7d20\u306e\u5909\u63db\u51e6\u7406\uff08key, value \u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u89e3\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u9023\u7d50\u7528\u306e\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\uff09\u3092\u3057\u3066\u8fd4\u3057\u3001<\/p>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e BiFunction \u3067\u8fd4\u3055\u308c\u305f\u5024\u3092\u30b7\u30b9\u30c6\u30e0\u306e\u6539\u884c\u6587\u5b57\u3092\u52a0\u3048\u3066\u7d50\u5408\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduce -------------<br \/>reduceResult<br \/>JDK 1.1.7 = Brutus<br \/>Java SE 9 = <br \/>JDK 1.1.8 = Chelsea<br \/>Java SE 8 = null<br \/>JDK 1.1.5 = Pumpkin<br \/>JDK 1.1.6 = Abigail<br \/>J2SE 1.2 = Playground<br \/>JDK 1.1.4 = Sparkler<br \/>Java SE 7 = Dolphin<br \/>Java SE 6 = Mustang<br \/>J2SE 1.2.2 = Cricket<br \/>J2SE 1.3.1 = Ladybird<br \/>J2SE 1.2.1 = null<br \/>J2SE 1.3 = Kestrel<br \/>J2SE 1.4 = Merlin<br \/>J2SE 5.0 = Tiger<br \/>J2SE 1.4.2 = Mantis<br \/>J2SE 1.4.1 = Hopper<\/p>\n<p><strong>key \u306b\u3088\u308b\u30ea\u30c7\u30e5\u30fc\u30b9<\/strong><\/p>\n<blockquote>\n<p><font color=\"#666666\">String reduceKeysResult = map.reduceKeys(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key -&gt; key.length() &gt; 9 ? key : null,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (s1, s2) -&gt; s1 + System.getProperty(\"line.separator\") + s2);<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u7b2c\u4e8c\u5f15\u6570\u306e Function \u3067\u8981\u7d20\u306e\u5909\u63db\u51e6\u7406 key \u304c 9 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001key \u3092\u8fd4\u3057\u3001<\/p>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e BiFunction \u3067\u8fd4\u3055\u308c\u305f\u5024\u3092\u30b7\u30b9\u30c6\u30e0\u306e\u6539\u884c\u6587\u5b57\u3092\u52a0\u3048\u3066\u7d50\u5408\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceKeys -------------<br \/>reduceKeysResult<br \/>J2SE 1.2.2<br \/>J2SE 1.3.1<br \/>J2SE 1.2.1<br \/>J2SE 1.4.2<br \/>J2SE 1.4.1<\/p>\n<p><strong>value \u306b\u3088\u308b\u30ea\u30c7\u30e5\u30fc\u30b9<\/strong><\/p>\n<blockquote>\n<p><font color=\"#666666\">String reduceValuesResult = map.reduceValues(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value -&gt; value.length() &gt; 4 &amp;&amp; value.length() &lt; 7 ? value : null,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (s1, s2) -&gt; s1 + System.getProperty(\"line.separator\") + s2);<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u7b2c\u4e8c\u5f15\u6570\u306e Function \u3067\u8981\u7d20\u306e\u5909\u63db\u51e6\u7406 value \u304c 4 \u6587\u5b57\u3088\u308a\u9577\u304f\u3001\u304b\u3064 value \u304c 7 \u6587\u5b57\u3088\u308a\u77ed\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001value \u3092\u8fd4\u3057\u3001<\/p>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e BiFunction \u3067\u8fd4\u3055\u308c\u305f\u5024\u3092\u30b7\u30b9\u30c6\u30e0\u306e\u6539\u884c\u6587\u5b57\u3092\u52a0\u3048\u3066\u7d50\u5408\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceValues -------------<br \/>reduceValuesResult<br \/>Brutus<br \/>Merlin<br \/>Tiger<br \/>Mantis<br \/>Hopper<\/p>\n<p><strong>Map.Entry \u306b\u3088\u308b\u30ea\u30c7\u30e5\u30fc\u30b9<\/strong><\/p>\n<p>String reduceEntriesResult = map.reduceEntries(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entry -&gt; entry.getKey().length() &gt; 7 &amp;&amp; entry.getValue().length() &gt; 7 ? entry.getKey() + \" = \" + entry.getValue() : null,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (s1, s2) -&gt; s1 + System.getProperty(\"line.separator\") + s2);<\/p>\n<p>\u7b2c\u4e8c\u5f15\u6570\u306e Function \u3067\u8981\u7d20\u306e\u5909\u63db\u51e6\u7406 Map.Entry \u306e key \u3068 value \u3092\u305d\u308c\u305e\u308c\u53d6\u5f97\u3001\u305d\u3057\u3066 key \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u304f\u304b\u3064 value \u304c 7 \u6587\u5b57\u3088\u308a\u9577\u3044\u5024\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3001<\/p>\n<p>Map.Entry \u306e key, value \u3092\u4e00\u3064\u306e\u6587\u5b57\u5217\u3068\u3057\u3066\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u89e3\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u9023\u7d50\u7528\u306e\u6587\u5b57\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e BiFunction \u3067\u8fd4\u3055\u308c\u305f\u5024\u3092\u30b7\u30b9\u30c6\u30e0\u306e\u6539\u884c\u6587\u5b57\u3092\u52a0\u3048\u3066\u7d50\u5408\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceEntries -------------<br \/>reduceEntriesResult<br \/>J2SE 1.2 = Playground<br \/>JDK 1.1.4 = Sparkler<br \/>J2SE 1.3.1 = Ladybird<\/p>\n<p><strong>reduceValuesToInt<\/strong><\/p>\n<blockquote>\n<p><font color=\"#666666\">int reduceMaxValuesResult = map.reduceValuesToInt(1,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String::length,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Integer::max);<\/font><\/p>\n<\/blockquote>\n<p>\u7b2c\u4e8c\u5f15\u6570\u306e ToIntFunction \u3067 value \u306e\u6587\u5b57\u5217\u306e\u9577\u3055\u3092\u8fd4\u3057\uff08int \u5024)\u3001<\/p>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e\u57fa\u6e96\u5024\u3092\u5143\u306b\u3001<\/p>\n<p>\u7b2c\u56db\u5f15\u6570\u306e IntBinaryOperator \u3067\u6700\u5927\u5024\u3092\u6c42\u3081\u308b\u7d2f\u7a4d\u51e6\u7406\u3092\u884c\u3044\u6700\u5927\u5024\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- reduceMaxValuesResult -------------<br \/>10<\/p>\n<p>\u3053\u308c\u3067\u3001\u3056\u3063\u304f\u308a\u8a66\u3057\u3066\u307f\u305f\u306e\u3067\u304a\u7d42\u3044\u3067\u3059\u3002<\/p>\n<p>(\u25cb\uff65\u03c9\uff65)\uff89------------- \u304a\u7d42\u3044\uff01 -------------<\/p>\n<p>\u4eca\u56de\u306f\u8a66\u3055\u306a\u304b\u3063\u305f\u3051\u3069\u6b21\u306e\u3088\u3046\u306a\u512a\u308c\u3082\u306e\u304c Java SE 8 \u304b\u3089\u8ffd\u52a0\u3055\u308c\u3066\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">p<font size=\"3\">ublic static &lt;K&gt; ConcurrentHashMap.KeySetView&lt;K,Boolean&gt; newKeySet()<\/font><\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u578b\u304b\u3089Boolean.TRUE\u3078\u306e\u3001ConcurrentHashMap\u306b\u9023\u52d5\u3059\u308b\u65b0\u3057\u3044Set\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>K - \u8fd4\u3055\u308c\u308b\u30bb\u30c3\u30c8\u306e\u8981\u7d20\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u65b0\u3057\u3044\u30bb\u30c3\u30c8<\/font><\/p>\n<p><font color=\"#666666\" size=\"3\">public static &lt;K&gt; ConcurrentHashMap.KeySetView&lt;K,Boolean&gt; newKeySet(int initialCapacity)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u578b\u304b\u3089Boolean.TRUE\u3078\u306e\u3001ConcurrentHashMap\u306b\u9023\u52d5\u3059\u308b\u65b0\u3057\u3044Set\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u578b\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>K - \u8fd4\u3055\u308c\u308b\u30bb\u30c3\u30c8\u306e\u8981\u7d20\u578b<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>initialCapacity - \u5b9f\u88c5\u306f\u3001\u3053\u306e\u591a\u6570\u306e\u8981\u7d20\u3092\u683c\u7d0d\u3059\u308b\u3088\u3046\u306b\u5185\u90e8\u306e\u30b5\u30a4\u30ba\u8a2d\u5b9a\u3092\u5b9f\u884c\u3059\u308b\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u623b\u308a\u5024:<br \/>\u65b0\u3057\u3044\u30bb\u30c3\u30c8<\/font><\/p>\n<p><font color=\"#666666\">\u4f8b\u5916:<br \/>IllegalArgumentException - \u8981\u7d20\u306e\u521d\u671f\u5bb9\u91cf\u304c\u8ca0\u306e\u5834\u5408<\/font><\/p>\n<\/blockquote>\n<p>Java SE 8 \u304b\u3089 Map \u304c\u5f37\u529b\u306b\u306a\u3063\u305f\u3002<\/p>\n<p>\u7279\u306b ConcurrentHashMap \u306f\u3001J2SE5.0 \u306e\u6642\u3068\u6bd4\u3079\u308b\u3068\u304b\u306a\u308a\u4f7f\u3044\u52dd\u624b\u304c\u3088\u304f\u306a\u3063\u305f\u3002(^_^)<\/p>\n<p>\u3055\u3066\u3001\u3053\u3053\u3067\u3082\u3046\u4e00\u5ea6 ConcurrentHashMap \u306e\u7279\u5fb4\u3092\u601d\u3044\u51fa\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>ConcurrentHashMap \u306f\u3001\u3059\u3079\u3066\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5171\u901a\u306e\u30ed\u30c3\u30af\u3067\u540c\u671f\u5316\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3092\u4e00\u5ea6\u306b\u4e00\u3064\u306e\u30b9\u30ec\u30c3\u30c9\u306b\u9650\u5b9a\u3059\u308b\u4ee3\u308f\u308a\u306b\u3001<\/p>\n<p>\u30ed\u30c3\u30af\u30b9\u30c8\u30e9\u30a4\u30d4\u30f3\u30b0\u3068\u3044\u3046\u5c0f\u3055\u306a\u7c92\u5ea6\u306e\u30ed\u30c3\u30af\u65b9\u5f0f\u3092\u63a1\u7528\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u4e26\u884c\u51e6\u7406\u80fd\u529b\u3092\u9ad8\u3081\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>ConcurrentHashMap \u306f\u3001Iterator \u304a\u3088\u3073 Enumeration \u306f\u3001\u3042\u308b\u6642\u70b9\u307e\u305f\u306f\u53cd\u5fa9\u5b50\/\u5217\u6319\u306e\u4f5c\u6210\u4ee5\u964d\u306e\u30cf\u30c3\u30b7\u30e5\u30c6\u30fc\u30d6\u30eb\u306e\u72b6\u614b\u3092\u53cd\u6620\u3059\u308b\u8981\u7d20\u3092\u8fd4\u3059\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001<\/p>\n<p>ConcurrentModificationException \u3092\u30b9\u30ed\u30fc\u3059\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u306a\u306b\u3088\u308a\u8208\u5473\u6df1\u3044\u306e\u306f\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u6642\u306b\u306f\u30d6\u30ed\u30c3\u30af\u3059\u308b\u3053\u3068\u304c\u306a\u304f\u3001\u66f4\u65b0\u306b\u3064\u3044\u3066\u306f\u30e6\u30fc\u30b6\u30fc\u304c\u4e26\u884c\u30ec\u30d9\u30eb\u3092\u8a2d\u5b9a\u3067\u304d\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u6700\u5f8c\u306e\u4e26\u884c\u30ec\u30d9\u30eb\u3092\u8a2d\u5b9a\u3067\u304d\u308b\u3068\u8a00\u3046\u3068\u3053\u308d\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>ConcurrentHashMap \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3059\u308b\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f 5 \u7a2e\u985e\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u4e2d\u3067\u4e26\u884c\u30ec\u30d9\u30eb\u3092\u8a2d\u5b9a\u3067\u304d\u308b\u306e\u306f\u6b21\u306e\u5f15\u6570\u3092\u6301\u3064\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u3059\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\" size=\"3\">public ConcurrentHashMap(int initialCapacity,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float loadFactor,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int concurrencyLevel)<\/font><\/p>\n<p><font color=\"#666666\">\u6307\u5b9a\u3055\u308c\u305f\u8981\u7d20\u6570(initialCapacity)\u3001\u30c6\u30fc\u30d6\u30eb\u5bc6\u5ea6(loadFactor)\u304a\u3088\u3073\u4e26\u884c\u66f4\u65b0\u6570\u306e\u3057\u304d\u3044\u5024(concurrencyLevel)\u306b\u57fa\u3065\u304f\u521d\u671f\u30c6\u30fc\u30d6\u30eb\u30fb\u30b5\u30a4\u30ba\u3067\u3001\u65b0\u3057\u3044\u7a7a\u306e\u30de\u30c3\u30d7\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u30d1\u30e9\u30e1\u30fc\u30bf:<br \/>initialCapacity - \u521d\u671f\u5bb9\u91cf\u3002\u8ca0\u8377\u4fc2\u6570\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u5b9f\u88c5\u306f\u3053\u306e\u6570\u306e\u8981\u7d20\u3092\u683c\u7d0d\u3067\u304d\u308b\u3088\u3046\u306b\u5185\u90e8\u306e\u30b5\u30a4\u30ba\u8a2d\u5b9a\u3092\u884c\u3046\u3002<br \/>loadFactor - \u521d\u671f\u30c6\u30fc\u30d6\u30eb\u30fb\u30b5\u30a4\u30ba\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306e\u8ca0\u8377\u4fc2\u6570(\u30c6\u30fc\u30d6\u30eb\u5bc6\u5ea6)<br \/>concurrencyLevel - \u4e26\u884c\u3057\u3066\u66f4\u65b0\u3057\u3066\u3044\u308b\u30b9\u30ec\u30c3\u30c9\u306e\u63a8\u5b9a\u6570\u3002\u5b9f\u88c5\u306f\u3053\u306e\u5024\u3092\u30b5\u30a4\u30ba\u8a2d\u5b9a\u306e\u30d2\u30f3\u30c8\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u308b\u3002<\/font><\/p>\n<p><font color=\"#666666\">\u4f8b\u5916:<br \/>IllegalArgumentException - \u521d\u671f\u5bb9\u91cf\u304c\u8ca0\u3067\u3042\u308b\u304b\u3001\u8ca0\u8377\u4fc2\u6570\u307e\u305f\u306fconcurrencyLevel\u304c\u6b63\u3067\u306a\u3044\u5834\u5408<\/font><\/p>\n<\/blockquote>\n<p>\u7b2c\u4e09\u5f15\u6570\u306e int concurrencyLevel \u304c\u4e26\u884c\u30ec\u30d9\u30eb\u306b\u3042\u305f\u308a\u307e\u3059\u3002<\/p>\n<p>Java SE 8 \u306e API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3067\u306f\u521d\u671f\u5bb9\u91cf\u3001\u8ca0\u8377\u4fc2\u6570\u3001\u4e26\u884c\u30ec\u30d9\u30eb\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u660e\u8a18\u3055\u308c\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002\uff08\u521d\u671f\u5bb9\u91cf\u306f 16 \u3068\u3042\u308a\u307e\u3057\u305f)<\/p>\n<p>\u30bd\u30fc\u30b9\u3092\u8997\u3044\u3066\u307f\u308b\u3068\u521d\u671f\u5bb9\u91cf 16, \u8ca0\u8377\u4fc2\u6570 0.75f, \u4e26\u884c\u30ec\u30d9\u30eb 16 \u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u6614\u3068\u5909\u308f\u3063\u3066\u7121\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u4e26\u884c\u30ec\u30d9\u30eb\u306e\u8a2d\u5b9a\u3067\u5927\u304d\u306a\u9055\u3044\u304c\u3067\u308b\u306e\u304b\u3064\u304e\u306e\u3088\u3046\u306a ConcurrentHashMap \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\u3057\u3066\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<blockquote>\n<p><font color=\"#666666\">ConcurrentHashMap&lt;Long, Long&gt; map = new ConcurrentHashMap&lt;&gt;();<br \/>ConcurrentHashMap&lt;Long, Long&gt; map2 = new ConcurrentHashMap&lt;&gt;(16, 0.75f, 1);<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u4e0b\u8a18 udDate() \u30e1\u30bd\u30c3\u30c9\u3092\u540c\u6642\u306b\u5b9f\u884c\u3059\u308b\u30b9\u30ec\u30c3\u30c9\u3092 32 \u500b\u4f5c\u3063\u3066\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>CompletableFuture&lt;Void&gt; cnt_1 = CompletableFuture.runAsync(() -&gt; upDate.upDate()); \u3053\u3093\u306a\u306e\u3092 32 \u500b (^_^;)<\/p>\n<blockquote>\n<p><font color=\"#666666\">void upDate() {<br \/>&nbsp;&nbsp;&nbsp; for (long i = 0; i &lt; 100_000_000; i++) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.computeIfAbsent(i, (k) -&gt; k);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((i &amp; 0b1) == 0) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.remove(i);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp;&nbsp; for (long i = 0; i &lt; 100_000_000; i++) {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.computeIfAbsent(i, (k) -&gt; k * 10);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map.getOrDefault(i, - 1L);<br \/>&nbsp;&nbsp;&nbsp; }<br \/>}<br \/><\/font><\/p>\n<\/blockquote>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>ConcurrentHashMap&lt;Long, Long&gt; map = new ConcurrentHashMap&lt;&gt;(); \/\/ 5\u520633\u79d214428361700004189<\/p>\n<p>ConcurrentHashMap&lt;Long, Long&gt; map2 = new ConcurrentHashMap&lt;&gt;(16, 0.75f, 1); \/\/ 34\u520642\u79d24334219810002651<\/p>\n<p>\u51c4\u304f\u5927\u5dee\u304c\u3064\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u5b9f\u884c\u74b0\u5883\u306f\u3001\u5148\u307b\u3069\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3057\u3066\u3044\u308b\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3067\u8ad6\u7406 CPU \u6570 32 \u500b\u3001VM \u30aa\u30d7\u30b7\u30e7\u30f3\u306e ForkJoinPool \u306e\u5236\u9650\u7121\u3057\u3067\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4ee5\u4e0a\u3001ConcurrentHashMap \u3067\u306e\u304a\u904a\u3073\u306f\u3053\u308c\u3067\u304a\u7d42\u3044\u3067\u3059\u3002<\/p>\n<div id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0d2b9ac5-32f6-4169-863a-e23c8c91ac52\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">Hatena \u30bf\u30b0: <a href=\"http:\/\/b.hatena.ne.jp\/t\/Java\" rel=\"tag\">Java<\/a><\/div>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D2048&title=Java%208%20%E6%99%82%E4%BB%A3%E3%81%AE%20ConcurrentHashMap%20%E3%81%A7%E9%81%8A%E3%82%93%E3%81%A7%E3%81%BF%E3%81%9F%E3%80%82' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D2048&t=Java%208%20%E6%99%82%E4%BB%A3%E3%81%AE%20ConcurrentHashMap%20%E3%81%A7%E9%81%8A%E3%82%93%E3%81%A7%E3%81%BF%E3%81%9F%E3%80%82' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"http:\/\/yucchi.jp\/blog\/?p=2048\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"http:\/\/yucchi.jp\/blog\/?p=2048\" data-text=\"Java 8 \u6642\u4ee3\u306e ConcurrentHashMap \u3067\u904a\u3093\u3067\u307f\u305f\u3002\" data-lang=\"ja\">Tweet<\/a><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u307e\u305f\u307e\u305f Blog \u306e\u66f4\u65b0\u3092\u3055\u307c\u3063\u3066\u3044\u307e\u3059\u3002 \u3068\u8a00\u3046\u3053\u3068\u3067\u9069\u5f53\u306a\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u66f8\u3044\u3066\u307f\u307e\u3059\u3002 ConcurrentHashMap J2SE5.0 \u3067 java.util.concurrent \u306b ConcurrentHashMap \u304c\u5c0e\u5165\u3055\u308c\u307e\u3057\u305f\u3002 ConcurrentHashMap \u306f\u5bb9\u6613\u306b\u5b89\u5168\u306b\u4e26\u884c\u51e6\u7406\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u4f5c\u3089\u308c\u307e\u3057\u305f\u3002 Collections.synchronizedMap \u3063\u3066\u306e\u3082\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u306f\u4f7f\u3044\u65b9\u304c\u5fae\u5999\u3067\u8a73\u3057\u3044\u8aac\u660e\u306f\u7701\u7565\u3057\u307e\u3059\u304c Iterator \u306a\u3069\u306e\u53cd\u5fa9\u51e6\u7406\u3067 ConcurrentModificationException \u3092\u30b9\u30ed\u30fc\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002 Col\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[17],"class_list":["post-2048","post","type-post","status-publish","format-standard","hentry","category-java","tag-java"],"_links":{"self":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2048"}],"version-history":[{"count":3,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2048\/revisions"}],"predecessor-version":[{"id":2052,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2048\/revisions\/2052"}],"wp:attachment":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2048"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}