Questions tagged [concurrenthashmap]

The Java ConcurrentHashMap data structure. The ConcurrentHashmap is a hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. It allows concurrent modification of the Map from several threads without the need to block them

The Java ConcurrentHashMap data structure.

This class provides a thread-safe variant of HashMap.

811 questions
-1
votes
2 answers

Getting empty CSV files

I am trying to write hashmap data into CSV files but I see empty files being generated. Here is the following code that I am using: String fileName for (String key : concurrentHashMap.keySet()) { logInfo(key + ": ")//gives the name of…
RV_Dev
  • 435
  • 1
  • 7
  • 21
-1
votes
1 answer

How to read values of a key with start and end limit in Hashmap?

I am having HashMap testmap; Which is having data with multiple keys this way, { status = [1, 2, 3, 4, 5], data = [ [1, 2, 3, 4, 5, 6], [7, 8 9, 10, 11, 12], [13, 14 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], …
Sandy
  • 313
  • 1
  • 8
  • 23
-1
votes
1 answer

fast non-lock hashmap or hashmap in Java?

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…
-1
votes
2 answers

Read and write in a concurrenthashmap

I have doubt understanding concurrenthashmap . If a section of conc hashmap is locked up by a writer thread then is it possible for a reader thread to read the same section of hashmap map simultaneously ? or does it need the lock to be released from…
jayendra bhatt
  • 1,337
  • 2
  • 19
  • 41
-1
votes
2 answers

How to add elements to ConcurrentHashMap using ExecutorService

I have a requirement of reading User Information from 2 different sources (db) per userId and storing consolidated information in a Map with key as userId. Users in numbers can vary based on period they have opted for. Group of users may belong to…
Suvasis
  • 1,451
  • 4
  • 24
  • 42
-1
votes
1 answer

ConcurrentHashMap vs HSQLDB in heavy traffic

I am using ConcurrentHashMap as cache DB. Every 3 minutes I get objects from my real db and update ConcurrentHashMap values with new one. I have only 100 objects in map and user who came from web only read ConcurrentHashMap objects not insert or…
maskapsiz
  • 244
  • 5
  • 23
-1
votes
1 answer

HashMap remove after a fix time

I want to remove the value from hashmap after 1/2 an hour of putting it. pls suggest. Ex:- if I am putting some data in HashMap at 10:30 am, then I want to remove it at 11.00 am.
Deepesh Uniyal
  • 923
  • 3
  • 20
  • 44
-1
votes
2 answers

How can I calculate percentile in java without using any other library

I am trying to calculate 95th Percentile from the data sets which I have populated in my below ConcurrentHashMap. I am interested in finding out how many calls came back in 95th percentile of time My Map will look like this and it will always be…
user1813228
-1
votes
1 answer

ConcurrentHashMap and threads

ConcurrentHashMap allow conurrent modification of the Map elements from several threads without the need to block them but HashMap block the whole HashMap object and not elements of it as in ConcurrentHashMap right? But what if one thread get the…
FrankD
  • 859
  • 4
  • 19
  • 31
-1
votes
1 answer

ConcurrentHashMap with complicated objects

I've taken some concurrent LRU cache implementation from the web, they have there HashMap and synchronized blocks. What I want is to use ConcurrentHashMap and avoid (where posible) using synchronized blocks. I've put ConcurrentHashMap instead of…
Alex A. Renoire
  • 361
  • 1
  • 2
  • 19
-2
votes
0 answers

Concurrent execution of remove and get in java ConcurrentHashMap

I was reading the implementation of Java11 Concurrent Hashmap. Below is the snipped of get: public V get(Object key) { Node[] tab; Node e, p; int n, eh; K ek; int h = spread(key.hashCode()); if ((tab = table) !=…
-2
votes
1 answer

Why does this code get stuck in infinite loop

public void bad() { final ConcurrentMap chm = new ConcurrentHashMap<>(); final String key = "1"; chm.computeIfAbsent(key, __ -> { chm.remove(key); return 1; }); } Of…
-2
votes
2 answers

How to maintain uniqueness of key in hashmap internally

Everyone know hashmap contain unique key. But i want know how it maintain uniqueness? Suppose we inserted 100 data into the hashmap, After that we insert duplicate key and value in the same hashmap. I know it will override the value. But i want to…
Jatin Bansal
  • 123
  • 8
-2
votes
2 answers

Why there is difference in output by just changing the key values in ConcurrentHashMap

If you see this image, you would find that I have just changed the keys and I found surprisingly two different results. In left hand side I found four strings as output while in right hand side only three strings as output. Can some one make me…
-2
votes
1 answer

Adding concurrency with iterating over a collection, mapping to multiple hash maps and reducing to one

Have a specific use case and not too sure of the best approach. So the current approach right now is that I'm iterating over a collection of objects (closeable iterator) and mapping them in a hashmap (dealing with conflicts appropriately, comparing…
SS'
  • 819
  • 1
  • 8
  • 18