On Tue, Oct 18, 2011 at 3:24 PM, Christopher Pisz
I want to do something simple, but implementing it seems awfully complex.
You've left a lot of the requirements unstated, but you seem to be talking about cross-thread communication, and that domain is fraught with peril. It's inherently complex.
All I want to do is wait for a specified amount of time for a member variable of my class to equal a certain value.
So, is some other thread going to set it to that value? If not, we could wait a long time... Apparently you'd need to protect both the 'set' access and the testing access. You also seem to be stating two different behaviors in the sentence above: - Do not return until the variable has been set as desired. - Do not wait longer than a specified timeout. (Then what? Exception? Return a flag value?) I haven't messed with cross-thread communication myself, so any example code I propose is quite likely to be horribly wrong. I'm merely suggesting that your initial mail may not be clear enough for people who understand this domain to give you a solid answer.