Is java.util.Hashtable thread safe?

后端 未结 9 1258
名媛妹妹
名媛妹妹 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:18

    If you look into Hashtable code, you will see that methods are synchronized such as:

    public synchronized V get(Object key) 
     public synchronized V put(K key, V value)
     public synchronized boolean containsKey(Object key)
    

    You can keep pressing on control key (command for mac) and then click on any method name in the eclipse to go to the java source code.

提交回复
热议问题