ReferenceCountedArray in a multithreaded application

Hello guys!

I have an audio application on windows, got some simple audioplayers in a mixer and some gui to set volume, FX and the others. Now, i put a Synthesizersound based midi panel into that. The user can switch the sounds of the Synthesizer, so i need to modify the sounds member variable of Synthesizer class, which is a ReferenceCountedArray. In the beginning, it happens well, but we need to change it until the program (music, gui reflections) is running. Now, until running I cant replace the SynthesizerSounds, because i got threading errors randomly. This happens then i use the add() method of ReferenceCountedArray. I made a single thread to do this thing, but the problem is still standing, and now i get annoying R2D2 noises in my music too… :frowning:

Please help me,
Ervin