I'm having a bit of trouble with concurrency. The situation is as follows:
I have a method which adjusts brightness like so (it is executed in the UI thread):
public void adjustBrightness(final float brightness) {
window_object.setBrightness(brightness);
window_object2.setBrightness(brightness);
}
The setBrightness method called on those objects is the second block of code in this question:
Clean way to implement gradual fading of brightness in Android?
As you can see, that block of code executes within another thread. This is problematic, because it means that setBrightness returns as soon as the thread is started, causing window_object2 to adjust its brightness whilst window_object is still adjusting. I do not want them to execute concurrently!
How can I enforce sequential execution of these methods such that they do not interlace? Keep in mind I need methods which are considered 'safe', so I don't get obscure concurrency bugs.
Thanks.