Share an array between threads in java

Solution 1:

The AtomicReferenceArray will give you the semantics you are looking for. So effectively, an array with volatile elements.

In technical terms, if the read of some element in the array sees a write (of the same element), then the read will synchronize with that write. So there will be a happens-before edge between the write and the read.

Solution 2:

You can try using CopyOnWriteArrayList, but from what you describe seems that Queue is the data structure that fits your needs the most. You have a data producer (your supplier thread) and consumer (your renderer thread). So, seems like Queue really gives you what you need. Read about the Queue interface, and choose the queue implementation you need, probably LinkedBlockingQueue