2 ms·
This was over 30 years ago when there was still a lack of awareness that locks don't compose [0]. Look at the early JRE classes like Vector, Hashtable, and Stri
by layer8 4y ago
This was over 30 years ago when there was still a lack of awareness that locks don't compose [0]. Look at the early JRE classes like Vector, Hashtable, and StringBuffer, whose operations are synchronized. The idea was that since you'd potentially want to synchronize access to any mutable object (because you'd want to be able to share any object between threads), and most objects are mutable, that the most convenient solution would be for every object to have that functionality built in.
[0] https://en.wikipedia.org/wiki/Lock_(computer_science)#Lack_of_composability https://en.wikipedia.org/wiki/Lock_(computer_science)#Lack_o...