No particularly good reason. It probably seemed like a good idea at the time, but in practice, even when you need multi-threaded access to a hash table, synchronization is usually needed on coarser grained application-level methods rather than the little Hashtable methods. All it does is lure inexperienced developers into thinking their code is threadsafe because the Hashtable they use is threadsafe. It isn't.
This is why, when the Collections framework was introduced in JDK 1.2, none of its classes were synchronized. This is also one of the reasons why you should always prefer HashMap over Hashtable and ArrayList over Vector. God only knows why everyone still loves to use an old, bloated, misconceived, superfluous legacy class like Vector.
Lot of people learned about Vector and Hashtable before 1.2
Including me, and Peter. Yes, we too once walked in darkness as you do now, Stefan. But one day we read the Epistile of the Prophet Joshua to the Philistines, and saw the Light. Now we seek to share this knowledge with others, that they may know true happiness. Or failing that, for those who reject the teachings of Joshua, we must strive to prevent them from spreading their vile corruption to others.
"I'm not back." - Bill Harding, Twister
Peter den Haan
posted 14 years ago
Originally posted by Stefan Wagner: Why learn something new, if it is more useful only in rare circumstances? Vector is in head, ArrayList in Javadocs.
O ye philistine, doth this mean that thou dost access the Vector through any other path than the List interface? And if thou doest this as the Prophet Joshua hath decreed, what avail thee the javadocs?
PS. Does this mean that you access the Vector through anything other than the List interface? And if you do, as is best practice, what do you need to consult the javadocs for?
PS2. I strongly disagree with the "only rarely useful" bit. [ July 27, 2004: Message edited by: Peter den Haan ]