• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Vector class is a Threadsafe

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unlike the new collection implementations, Vector is synchronized.


Vector
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does say in the API that
Unlike the new collection implementations, Vector is synchronized.
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ernest Friedman-Hill , thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic