I made a custom FileTreeComponentEx which has a buildDirectory(String dir) function. This function, when called from the UI Thread, will create a new Thread that fills up the TreeView with the contents of a directory.
In this thread I have to use MessageManagerLocks every time I add a new TreeViewItem and set its text (because this will initiate a repaint() I guess).
The problem is that when I call stopThread(10000) from the UI Thread to stop my Thread that is filling the TreeView with the directory contents, I get a deadlock. It seems that the problem is the use of the MessageManagerLock in that particular thread.
In the JUCE help about MessageManagerLock it is stated:
“Another caveat is that using this in conjunction with other CriticalSections can create lots of interesting ways of producing a deadlock! In particular, if your message thread calls stopThread() for a thread that uses these locks, you’ll get an (occasional) deadlock…”
Why is that and what can I do about it?
Why does the stopThread() function fail when the Message Manager is locked (or vice versa) ?