I have data structure (i.e. queue, stack or list). There is infinite loop (in thread 1) that inserts objects into that data structure, and there is another infinite loop (in thread 2) that takes objects from that data structure and does some processing on it. I don't want the processing loop to block the insert loop.
How can I do this correctly in Java, to share a single data structure between two threads with synchronization and concurrent read/write from the two different threads? Is there any data structure in java concurrent API (java 7) that I can use? is there any recommendation to solve this issue?