0

I get String value from client and if this value does not fit my parameters I add this value to my Set<String>. And every 10 min in scheduled method I get this values and try perform actions on them and remove from Set. I need Set in which I write and read values. Wrute one methos and read another method. I need cuncurent Set or queue for it.

I try this:

private CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<>();

But I found that CopyOnWriteArrayList has large overhead. How can I write and read String values in java the object of a joint access?

user5620472
  • 2,722
  • 8
  • 44
  • 97
  • Have you looked into [`ConcurrentHashMap`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html)? You can use it like a set but just setting the keys. – Rico Kahler Feb 21 '17 at 04:02
  • I have 1 value String. HashMap has 2 - key value. And I need unuque values – user5620472 Feb 21 '17 at 04:04
  • Refer to this question: ["Why there is no ConcurrentHashSet against ConcurrentHashMap "](http://stackoverflow.com/questions/6992608/why-there-is-no-concurrenthashset-against-concurrenthashmap) – Rico Kahler Feb 21 '17 at 04:09

0 Answers0