• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How are Vector and Hashtable synchronized?

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API mentions that Vector and Hashtable are synchronized. I'm curious what actually is synchronized and how I could tell from the API that it is synchronized? You can't synchronize a class and none of the methods that I can see listed have the modifier synchronized so what is that is actually makes these classes synchronized? ( I know I don't need to know much more than that they are synchronized for the test, but I'm just curious ).
TIA,
Rick
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The synchronized keyword is an implementation detail, like native, so it's not going to show up in the API docs.
Basically, every call in Vector and Hastable that gets an object, or sets an object, is synchronized. If you really want to look at the methods themselves, look at the source code for Vector and Hashtable. Source for all the Java classes comes with the JDK, usually in a file called src.jar.
 
Rick Reumann
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Rob, that makes sense. I didn't think of it synchronizing on the objects which I'd only see in implementation within the source code.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can in fact synchronize a class, or rather the object-invariant fields of the class, by declaring one or more of its static methods to be synchronized.
 
reply
    Bookmark Topic Watch Topic
  • New Topic