InterviewSolution
| 1. |
What All Collection Classes Are Inherently Thread-safe? |
|
Answer» In the initial COLLECTION classes like Vector, HashTable and Stack all the methods were synchronized to make these classes thread SAFE. Later implementations starting from Java 1.2 were not synchronized. Classes in java.util.concurrent package like CONCURRENTHASHMAP, CopyOnWriteArrayList also PROVIDES thread safety but with a different implementation that doesn't require MAKING all the methods synchronized. In the initial Collection classes like Vector, HashTable and Stack all the methods were synchronized to make these classes thread safe. Later implementations starting from Java 1.2 were not synchronized. Classes in java.util.concurrent package like ConcurrentHashMap, CopyOnWriteArrayList also provides thread safety but with a different implementation that doesn't require making all the methods synchronized. |
|