HashTable已经被淘汰了,不要在代码中再使用它

以下描述来自于HashTable的类注释:

If a thread-safe implementation is not needed, it is recommended to use HashMap in place of Hashtable. If a thread-safe highly-concurrent implementation is desired, then it is recommended to use java.util.concurrent.ConcurrentHashMap in place of Hashtable.

简单来说就是,如果你不需要线程安全,那么使用HashMap,如果需要线程安全,那么使用ConcurrentHashMap。HashTable已经被淘汰了,不要在新的代码中再使用它。

Concurrent--并发

猜你喜欢

转载自my.oschina.net/hfq/blog/1812621