This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Not using Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Not using Vector" Watch "Not using Vector" New topic

Not using Vector

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello All,
I am kindda confuse and to why you all say not using Vector. I mean the reason I would want to use Vector is it is synchorinized. Yep it is slower than List or ArrayList. Also ArrayList is not synchronized. So using Vector when we have to watch out for synchronization of data makes sense. Let me know!
Nate Johnson
Ranch Hand

Joined: May 13, 2002
Posts: 301
Have a look at Peter's advice in this thread...
You can use a vector, just be sure to use it right... although I would not recommend it.

scwcd, scjd, scjp<br /><a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a>
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Amish,
You can create a synchronized version thus:

But you are usually better off just creating the List unsynchronized and protecting it by syncrhonizing the methods that access or modify it. I don't think thread-safety is a good enough argument to use a stale class when there are much better alternatives.
Just my dos centavos,
Michael Morris
[ August 05, 2002: Message edited by: Michael Morris ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: Not using Vector
It's not a secret anymore!