当前位置:网站首页>Thread safe level

Thread safe level

2022-06-12 21:42:00 , country

immutable
Immutable objects must be thread safe , And never need extra synchronization .
Java Most basic numerical classes in the class library are as follows IntegerString and BigInteger It's all immutable .
Unconditional thread safety
The constraints specified by the class specification are still valid when the object is accessed by multiple threads , No matter how the runtime environment is arranged , No threads
Need any additional synchronization .
Such as Random ConcurrentHashMapConcurrent aggregate 、atomic
Conditional thread safety
Conditional thread safety classes can be thread safe for individual operations , But some sequences of operations may require external synchronization .
The most common example of conditional thread safety is traversal by Hashtable perhaps Vector Or the iterator returned
Non-thread safety ( Thread compatibility )
Thread compatible classes are not thread safe , But it can be used safely in a concurrent environment by using synchronization properly .
Such as ArrayList HashMap
Thread opposition
Thread opposites are those that are synchronized or not , Code that cannot be used concurrently in a multithreaded environment .
Ultimate Reality System.setOut()System.runFinalizersOnExit()
原网站

版权声明
本文为[, country]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202281349142570.html