'Java program for multithread environment -one thread to add data to collection and another thread to access it

I am new to java multi threading. I would like to write a program in which having 2 threads. One thread adds data to collection structure and other thread is trying to access it. How to implement the same. So do we have to use only concurrenthashmap as collection? Could you please help on this



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source