Which Java Collections are synchronized, which are not?
Example: HashSet is not synchronized
Thread safe Collections -
Thread safe without having to synchronize the whole map Very fast reads while write is done with a lock No locking at the object level Uses multitude of locks.
Object level synchronization Both read and writes acquire a lock Locking the collection has a performance drawback May cause contention
Vector
HashTable
CopyOnWriteArrayList
CopyOnWriteArraySet
Stack
Rest all are not thread safe