Question: I find myself in need of a data structure which only needs the ability to *enter objects*, *retrieve* and *delete* them (I have no interest in its size and etc..).
This data structure *will be accessed from multiple threads* both adding and getting specific objects.
Currently I am using in my program a concurrent HashMap:

```
key = object.hashCode()
data = object

```

The question: I was wondering this is the best way to go ? 

*Note*: 

* I *do not* add any object twice
* the only hashMap methods i use are *get*, *put*, *remove*.

Thanks alot!

Answer: 
Have a look at [java.util.concurrent.atomic](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/package-summary.html) package. 

> 
> A small toolkit of classes that support lock-free thread-safe programming on single variables.
> 
> 
> 

[AtomicReference](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html) is one solution. 

Refer to related SE question:

[When to use AtomicReference in Java?](https://stackoverflow.com/questions/3964211/when-to-use-atomicreference-in-java)
You could use a HashTable what is a thread safe version of HashMap. <https://docs.oracle.com/javase/7/docs/api/java/util/Hashtable.html>