File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes A Vector class is a Threadsafe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A Vector class is a Threadsafe" Watch "A Vector class is a Threadsafe" New topic
Author

A Vector class is a Threadsafe

PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212

A vector which says that it is a it is a Thread safe data structure.

But when i referred to the API none of its methods are synchronized like add , addElement ---.

Please let me know how a Vector class is Thread safe when none of its methods are synchronized.(Correct me if i am wrong)
Ryan Beckett
Ranch Hand

Joined: Feb 22, 2009
Posts: 192
Unlike the new collection implementations, Vector is synchronized.


Vector
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36520
    
  16
It does say in the API that
Unlike the new collection implementations, Vector is synchronized.
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Campbell thanks for the prompt response ,, but I did not get the answer.

My Question is " Are the methods of a Vector are synchronized "?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

PavanPL KalyanK wrote:
Please let me know how a Vector class is Thread safe when none of its methods are synchronized.(Correct me if i am wrong)


Just because the "synchronized" keyword doesn't show up in Sun's Javadocs doesn't mean the method implementation isn't synchronized. Have a look at the actual source code.


[Jess in Action][AskingGoodQuestions]
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Hey Ernest Friedman-Hill , thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A Vector class is a Threadsafe
 
Similar Threads
NX: Synchronization - those who passed??
Vector and Hashtable
Thread-safe
Threads in applications
Why Vector is made as a Legacy Class