I am working on Java 7.
I want to know if a method is containsthread safe for a HashSet object.
contains
A HashSet is initialized with a single thread. Then we end the HashSet with an immutable collection ( Collections.unmodifiableSet). After initialization, several threads call only the method contains.
Collections.unmodifiableSet
When I read the Javadoc, it is not clear to me.
In HashSet Javadoc we can read
This class implements the Set interface, supported by a hash table (actually an instance of HashMap).
...
Please note that this implementation is not synchronized.
And on the HashMap Javadoc , we can read:
, . , , . ( - , ; , , , .)
, contains .
, contains -?
: JVM (, IBM JVM)?
, concurrency (, , ) . concurrency . , ( , ).
, concurrency, , ( ) . , contains() , , . " " Java, Java concurrency .
contains()
, Collections.unmodifiableSet() final. , , , contains() Set
Collections.unmodifiableSet()
final
Set
Source: https://habr.com/ru/post/1670156/More articles:Find the difference in the value of one row with the rest of the row values in python pandas dataframe - pythonWhat do people mean when they say that there is no parent selector in css? - javascriptКак работает numpy.swapaxes? - pythonFailed - network error while loading zip file made by Ionic.Zip.dll - c #Symfony 3 WebSocketBundle PdoSessionHandler - phpWhy does this piece of code in the linux kernel NOT cause a dead loop? - memory-managementJavascript slide show attenuation - javascript1b and 1f in the GNU assembly - gasBash. The fastest and most efficient array search - performanceUser-user user-manager Mikrotik script needs improvement - scriptingAll Articles