I’ve written a thread that uses MessageManagerLock to change the UI. However, I sometimes get a deadlock when I try to shut down the thread.
The thread looks something like this:
…message loop could potentially acquire the lock here…
// grab the lock and do something useful
…do stuff here…
The call to stopThread happens in the context of the message loop (a buttonClicked callback). So - if the MessageManager happens to grab the lock as shown above and then wait for the thread to exit, the thread will never exit - it’s stuck waiting for the lock.
If there was a MessageManagerUnlock class, then it would be straightforward - I could just unlock the message loop temporarily while stopping the thread.
Other than that, I’m stumped. For this particular case, thread I can just use a Timer or an ActionBroadcaster instead.
But, I’m curious - anyone got any bright ideas? Am I just being dense?