<small id='ZV2kE'></small><noframes id='ZV2kE'>

          <bdo id='ZV2kE'></bdo><ul id='ZV2kE'></ul>

        <i id='ZV2kE'><tr id='ZV2kE'><dt id='ZV2kE'><q id='ZV2kE'><span id='ZV2kE'><b id='ZV2kE'><form id='ZV2kE'><ins id='ZV2kE'></ins><ul id='ZV2kE'></ul><sub id='ZV2kE'></sub></form><legend id='ZV2kE'></legend><bdo id='ZV2kE'><pre id='ZV2kE'><center id='ZV2kE'></center></pre></bdo></b><th id='ZV2kE'></th></span></q></dt></tr></i><div id='ZV2kE'><tfoot id='ZV2kE'></tfoot><dl id='ZV2kE'><fieldset id='ZV2kE'></fieldset></dl></div>
      1. <tfoot id='ZV2kE'></tfoot>

        <legend id='ZV2kE'><style id='ZV2kE'><dir id='ZV2kE'><q id='ZV2kE'></q></dir></style></legend>

        ConcurrentHashMap.newKeySet() 与 Collections.newSetFromMap()

        ConcurrentHashMap.newKeySet() vs Collections.newSetFromMap()(ConcurrentHashMap.newKeySet() 与 Collections.newSetFromMap())
        • <tfoot id='ZZ4PA'></tfoot>

          <small id='ZZ4PA'></small><noframes id='ZZ4PA'>

          <legend id='ZZ4PA'><style id='ZZ4PA'><dir id='ZZ4PA'><q id='ZZ4PA'></q></dir></style></legend>
        • <i id='ZZ4PA'><tr id='ZZ4PA'><dt id='ZZ4PA'><q id='ZZ4PA'><span id='ZZ4PA'><b id='ZZ4PA'><form id='ZZ4PA'><ins id='ZZ4PA'></ins><ul id='ZZ4PA'></ul><sub id='ZZ4PA'></sub></form><legend id='ZZ4PA'></legend><bdo id='ZZ4PA'><pre id='ZZ4PA'><center id='ZZ4PA'></center></pre></bdo></b><th id='ZZ4PA'></th></span></q></dt></tr></i><div id='ZZ4PA'><tfoot id='ZZ4PA'></tfoot><dl id='ZZ4PA'><fieldset id='ZZ4PA'></fieldset></dl></div>

          • <bdo id='ZZ4PA'></bdo><ul id='ZZ4PA'></ul>

                  <tbody id='ZZ4PA'></tbody>
                  本文介绍了ConcurrentHashMap.newKeySet() 与 Collections.newSetFromMap()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Java 8 引入了获取并发 Set 实现的新方法

                  Java 8 introduced new way to obtain a concurrent Set implementation

                  // Pre-Java-8 way to create a concurrent set
                  Set<String> oldStyle = Collections.newSetFromMap(new ConcurrentHashMap<>());
                  // New method in Java 8
                  Set<String> newStyle = ConcurrentHashMap.newKeySet();
                  

                  有什么理由更喜欢新方法吗?

                  Is there any reason to prefer new method?

                  有什么优点/缺点?

                  推荐答案

                  ConcurrentHashMap.newKeySet() 应该更高效一些,因为它移除了单层间接.Collections.newSetFromMap(map)主要是基于将操作重定向到map.keySet(),而ConcurrentHashMap.newKeySet()则非常接近 map.keySet() 本身(仅具有附加支持).

                  ConcurrentHashMap.newKeySet() should be somewhat more efficient as removes a single level of indirection. Collections.newSetFromMap(map) is mostly based on redirecting the operations to the map.keySet(), but ConcurrentHashMap.newKeySet() is very close to map.keySet() itself (just with additions support).

                  至于功能,我认为没有区别.

                  As for functionality, I see no difference.

                  这篇关于ConcurrentHashMap.newKeySet() 与 Collections.newSetFromMap()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                  • <bdo id='Wtqex'></bdo><ul id='Wtqex'></ul>

                      <tbody id='Wtqex'></tbody>

                    1. <small id='Wtqex'></small><noframes id='Wtqex'>

                      <tfoot id='Wtqex'></tfoot>

                        <legend id='Wtqex'><style id='Wtqex'><dir id='Wtqex'><q id='Wtqex'></q></dir></style></legend>

                        <i id='Wtqex'><tr id='Wtqex'><dt id='Wtqex'><q id='Wtqex'><span id='Wtqex'><b id='Wtqex'><form id='Wtqex'><ins id='Wtqex'></ins><ul id='Wtqex'></ul><sub id='Wtqex'></sub></form><legend id='Wtqex'></legend><bdo id='Wtqex'><pre id='Wtqex'><center id='Wtqex'></center></pre></bdo></b><th id='Wtqex'></th></span></q></dt></tr></i><div id='Wtqex'><tfoot id='Wtqex'></tfoot><dl id='Wtqex'><fieldset id='Wtqex'></fieldset></dl></div>