<<< Code that uses a tree map | Index | Code that uses a vector >>> |
These are obsolete (but not deprecated) Java collections, part of the original java.util. They synchronize each individual operation in a multithreaded program -- not what you want. (Generally, you want to synchronize a certain sequence of statements as opposed to a single statement.) The functionality of legacy collection classes is retrofitted into the latest Java API in a way that is best suitable for potentially thread-unsafe legacy code.
Vector // contains legacy methods no longer part of the collections framework // Vector is synchronized // For an alternative, see Collections.synchronizedList HashTable // similar to HashMap, but is synchronized Stack // subclass of Vector that implements a stack
Advice: do not use these legacy classes in your code! Instead,
ArrayList is the replacement of Vector
HashMap is the replacement of HashTable
Deque and ArrayDeque are replacements of Stack
<<< Code that uses a tree map | Index | Code that uses a vector >>> |