Concurrent threads adding to ArrayList at same time - what happens?
Posted
by Marcus
on Stack Overflow
See other posts from Stack Overflow
or by Marcus
Published on 2010-04-26T18:46:03Z
Indexed on
2010/04/26
18:53 UTC
Read the original article
Hit count: 296
We have multiple threads calling add(obj)
on an ArrayList
.
My theory is that when add
is called concurrently by two threads, that only one of the two objects being added is really added to the ArrayList
. Is this plausable?
If so, how do you get around this? Use a synchronized collection like Vector
?
© Stack Overflow or respective owner