Is java.util.Hashtable thread safe?

后端 未结 9 1273
名媛妹妹
名媛妹妹 2020-12-09 06:23

It\'s been a while since I\'ve used hashtable for anything significant, but I seem to recall the get() and put() methods being synchronized.

The JavaDocs don\'t ref

9条回答
  •  臣服心动
    2020-12-09 07:23

    Unlike the new collection implementations, Hashtable is synchronized. *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 ConcurrentHashMap in place of Hashtable.

    http://download.oracle.com/javase/7/docs/api/java/util/Hashtable.html

提交回复
热议问题