I am looking for a fast implementation that support multiple threads for storing mapping from integers to integers or double. I have tried ConcurrentHashMap but are not impressed with the speedup factor. I also think that I could implement one by myself if it is not too bad.
Asked
Active
Viewed 44 times
-1
-
You really ***really*** should not try to implement a concurrent implementation of hashmap yourself. ``ConcurrentHashMap`` really ***really*** is good at it. – Jean Logeart Feb 24 '16 at 16:26
-
Most likely, the bottleneck of your implementation does not come from ``ConcurrentHashMap`` but from other factors, such as disk reads, poor synchronization somewhere else ... – Jean Logeart Feb 24 '16 at 16:28
-
In my case it is pretty simple. Suppose I have an array of integers or doubles. I created once and will change the length or so. I would like to have multiple threads operating on the array. At each operation, a thread just change the value of the array. I'd like to have around 16-64 threads and the array is >64000 so I guess the collisions are not bad. – Benjamin Nguyen Feb 24 '16 at 16:33
-
If you could point me to some implementation, it would be awesome. – Benjamin Nguyen Feb 24 '16 at 16:34
-
Will the size of your array change through time? – Jean Logeart Feb 24 '16 at 16:36
-
Sorry for my misdescriptions. The array size does not change over time. A thread only change the value of an element not multiple elements. – Benjamin Nguyen Feb 24 '16 at 16:40
-
Please read [What topics can I ask about here?](http://stackoverflow.com/help/on-topic), [What types of questions should I avoid asking?](http://stackoverflow.com/help/dont-ask) and [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) before attempting to ask more questions. An excessive number of poorly received questions that are off-topic will get you banned from asking questions, and you do not want that do you? – Mar 03 '16 at 17:55
1 Answers
0
Since the size is fixed, you might want to use an AtomicIntegerArray
or an AtomicDoubleArray
from Guava.

Jean Logeart
- 52,687
- 11
- 83
- 118
-
Thanks a lot. Any other implementations ? I will compare them in whole to see which one is good for my purpose. – Benjamin Nguyen Feb 25 '16 at 15:16