• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Not using Vector  RSS feed

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
-Amish
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at Peter's advice in this thread...
http://www.coderanch.com/t/231476/threads/java/Sync
You can use a vector, just be sure to use it right... although I would not recommend it.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!