Currently I'm using the following construction:
while(continue)
{
if(somethingChanged)
{
draw();
}
}
Is this way of waiting efficient, or is there a better way to do this?
--
As requested, more info:
I'm drawing on a SurfaceView, with a Thread locking the Canvas and calling the onDraw(Canvas) method. When the thing I have drawn hasn't changed, I don't need to call the onDraw(Canvas) method, so I keep a boolean somethingChanged.
Also, when I touch the screen, I draw let's say a circle at the point of touch, so when I'm touching the screen, somethingChanged is true.
You can also use a wait() and make the other threads notify() this one when something has changed (if the somethingChanged is changed by other threads).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With