Analysis of hashtable source code of Java collection
•
Java
summary
Hashtable is also implemented based on hash table, which is similar to map, but hashtable is thread safe, and hashtable does not allow null key or value
Member variable
Like HashMap, the data structure of hashtable is implemented by array and linked list
Several member variables are the same as HashMap:
method
The hashtable method is basically the same as HashMap, except that the hashtable method adds the synchronized keyword to ensure that the hashtable is thread safe
Mainly talk about the differences between hashtable and HashMap:
There is a static method in the collections class: synchronizedmap (), which creates a thread safe map object and returns it as an encapsulated object.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码