File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How are Vector and Hashtable synchronized?

 
Rick Reumann
Ranch Hand
Posts: 281
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Rob Ross
Bartender
Posts: 2205
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic