There will be 500+ threads concurrently uploading an unique object to a bucket all the time.
In this case, which data structure/class i should use to implement bucket in java.
FYI:
I tried using ArrayList, Vector, ConcurrentHashMap, ArrayBlockingQueue, LinkedBlockingQueue.
ArrayList fails as it is not thread safe.
Vector consumes more time for insertion. (as the wait time to get the monitor lock is high)
… finally, I used ArrayBlockingQueue which sounds good on comparing others.
Suggest me if any other good class/ data structure exists for this case.
Contention will be very high, so you may want to look at lock-free wait-free implementations available or – to keep it simple – use ConcurrentHashMap.
Lock striping is the key benefit here, so that for read operations you have no lock, for write operations you only lock a subset of existing buckets, and you lock the entire hashtable only for rehashing.
You can find a bit more here:
Performance ConcurrentHashmap vs HashMap
Java Hashtable many accesses problem