Thread calculations, and another thread to use the calculations
Hi. I'm calculating a sine wave based on two given values. Now I have a thread calculating the sine wave values, but I'd like to have another thread to use them calculations and send them out through my sound card.
I'm processing the calculations whilst I'm moving the mouse cursor of an area of my jpanel.
The sound is really crackly due to the sound card is process the calculations, whilst newer calculations are being sent to it.
I'm thinking along the lines of:
Thread 1: calculations
Thread 2: sound card
Thread 2 = Locked
Thread 1 = calculates the values
Thread 2 = Unlocked
Thread 1 = Locked
Thread 1 --- Sends data to Thread 2 (Sound card)
Thread 1 = Unlocked
Any hints please if this is possible?