Best Java thread-safe locking mechanism for collections?

Posted by Simon on Stack Overflow See other posts from Stack Overflow or by Simon
Published on 2011-01-15T00:45:17Z Indexed on 2011/01/15 0:53 UTC
Read the original article Hit count: 127

Filed under:
|

What would be the least-slow thread-safe mechanism for controlling multiple accesses to a collection in Java?

I am adding objects to the top of a collection and i am very unsure what would be the best performing collection. Would it be a vector or a queue? I originally thought an ArrayList would be fast but i ran some experiments and it was very slow.

EDIT: In my insertion testing a Vector delared using volatile seems to be the fastest?

© Stack Overflow or respective owner

Related posts about java

Related posts about collections