This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread safe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "thread safe" Watch "thread safe" New topic
Author

thread safe

Blanka Li
Greenhorn

Joined: Feb 18, 2002
Posts: 13
"Vector and HashTable are the only classes that are thread-safe".
what is the meaning of "thread-safe" here? And why the two class are thread-safe?
thanks!
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Hello Blanka, wellcome to the Ranch
Thread safe means that it is safe for several threads call the methods of an object, because they are not going to be executed simultaneously. Imagine wanting to add an element at the same time an iterator is returned, or deleting other.
Because the code in the methods of Vector and HashTable are synchonized. One thread would have to wait before entering a method that is "protected" (synchronized on) by the same lock that has been adquired by another thread.
Read more on the Java Tutorial , and this Thinking in Java's chapter


SCJP2. Please Indent your code using UBB Code
Blanka Li
Greenhorn

Joined: Feb 18, 2002
Posts: 13
Jose Botella, thank you very very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: thread safe
 
Similar Threads
question from the jweb+
thread safe
vetor thread safe?
threadsafe objects
ActionServlet Thread Safe