Thread synchronization Java
<p>I am working on Android App and unable to synchronize View with Hardware.
Let me explain.</p>

<p>1) I mute and unmute microphone of Android based on random values (which are random sleeps) stored in array A, from within run  method of Thread 1.</p>

<p>2) I draw  blue pulses that reflects the mutes of microphone. This is done by independent View class. </p>

<p>3)I move a red line across the graph drawn in above view, by calling from within onTick of a countdown timer. </p>

<p>I start the two threads one after other, this way:</p>

<p>Thread1.start</p>

<p>counter.start();</p>

<p>How to synchronize both of these, I want to do three things at a time and avoid multiple threads. Three things are: Draw the pulses (which is constant) , make the red line move across x axis and touch the blue pulse as soon as the phone is muted, and keep moving every second, the width of pulse reflects duration of delay. as soon as microphone is about to be unmuted, red line should leave the pulse and move forward.</p>

<p>Currently, code is doing what I want. but there is no synchroization. Either microphone does its job first, or graph moves fast. They are not in Sync. </p>

<p>Is there a way to hold a thread, force it to behave as coutdowntimer or sync both of them.
I cannot embed the red line movement in thread 1 because, it will have to progress across x axis every second.</p>
