We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am hooking up my electric piano to processing using The MidiBus library. I'm basically playing around with visualising the notes played in different ways. This often includes adding some sort of object to an array or arraylist and then iterating through the list to call .update() which updates position, size etc for the object and draws it on the canvas.
However I often get the problem of "concurrent modification exception". I do not get this error when I run the code without the pian but just randomly call the note-pressed function. After some googling this leads me to believe that the error stems from me sometimes calling the notePressed() function, which creates a new object and add to the list, right in the middle of the update loop. Hence I am modifying the list whilst I am iterating over it.
So with that long introduction, here is my question:
Is there a way for me to tell processing "Call this function as soon as possible, but wait until next iteration of draw()"?
or alternativley : "Excecute this block of code without any interruption" ?
From my few qourses in Java i vaguely recall this issue beeing about synchronization, am I right?
Appreciate any help! :)