Is java.util.Hashtable thread safe?

后端 未结 9 1263
名媛妹妹
名媛妹妹 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条回答
  •  萌比男神i
    2020-12-09 07:13

    Yes, Hashtable thread safe, so only one thread can access a hashtable at any time

    HashMap, on the other side, is not thread safe (and thus 'faster').

提交回复
热议问题