Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

ArrayList versus Vector
What's the difference Vector and ArrayList. I have heard Vector is
not thread safe, but ArrayList is. I don't quite understand.

any ideas?


Report this thread to moderator Post Follow-up to this message
Old Post
jrefactors@hotmail.com
06-03-05 01:58 AM


Re: ArrayList versus Vector
<jrefactors@hotmail.com> wrote in message
news:1117737430.895431.202330@g47g2000cwa.googlegroups.com...
> What's the difference Vector and ArrayList. I have heard Vector is
> not thread safe, but ArrayList is. I don't quite understand.

Other way around.

But... as this is your second question about this subject, you might prefer
to lookup all this info yourself in the JavaDocs. It's all well explained on
a class/method/field base.

http://java.sun.com/j2se/1.5.0/docs/api/



Report this thread to moderator Post Follow-up to this message
Old Post
Skip
06-03-05 01:59 AM


Re: ArrayList versus Vector
On Thu, 2 Jun 2005 jrefactors@hotmail.com wrote:

> What's the difference Vector and ArrayList. I have heard Vector is
> not thread safe, but ArrayList is. I don't quite understand.
>
> any ideas?

You have things backwards. A Vector is synchronized and an ArrayList is
not synchronized. What this means is, if two threads attempt to access a
Vector it will be synchronized. One thread will have to wait until the
other thread is finished accessing the Vector. With an ArrayList you have
to create wrappers to synchronize access to the ArrayList or you will have
undefined behaviour.

I noticed this is your second question about things described in the JDK
documentation. You might want to get a copy of the documentation and read
it. Compare the section on Vector to the section on ArrayList. You can get
the docs from http://java.sun.com.

--
Send e-mail to: darrell dot grainger at utoronto dot ca


Report this thread to moderator Post Follow-up to this message
Old Post
.
06-03-05 01:59 AM


Re: ArrayList versus Vector
In article <1117737430.895431.202330@g47g2000cwa.googlegroups.com>,
<jrefactors@hotmail.com> wrote:
>What's the difference Vector and ArrayList. I have heard Vector is
>not thread safe, but ArrayList is. I don't quite understand.
>
>any ideas?

Neither is "thread safe", but Vector defaults to being synchronized.
Depending on how you use it, this could cause it to be thread safe or
it could cause it to deadlock.

If you want to write thread safe code, it is insufficient to simply
use synchronized data structures - your logic needs to be bullet proof
as well.

Cheers
Bent D
--
Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd
powered by emacs

Report this thread to moderator Post Follow-up to this message
Old Post
Bent C Dalager
06-03-05 02:08 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:44 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.