Immutable
Immutable object is always thread safe : after the object is created, it will never change, and there is non possibility for the threads see a different value of it.
Ex: String, Integer, BigInteger, Double ...
Data structure itself offers the synchronization:
Some class is designed for multi-threading, so its methods are already implemented to trait the synchronization problem : not assure the synchronization, but use fast-fail to tell the programmer there is a problem!
Ex : HashTable, Vector, java.util.concurrent.CopyOnWriteArrayList<E>
Ex : HashTable, Vector, java.util.concurrent.CopyOnWriteArrayList<E>
Data Structure need synchronization by programmer
Mono thread is always thread safe, in multi-threading, the
Ex: ArrayList、HashMap、SimpleDateFormat、Connection, ResultSet
No comments:
Post a Comment