Best Java thread-safe locking mechanism for collections?
- by Simon
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?