This is the correct way to have multiple threads update the GUI. It should not cause the application to hang.
If you are overly concerned, you could change your structure so that two of the threads merely send messages to the first, and only the first does GUI updates. This is unlikely to cause any visible impact.
I have an application which needs to update log to GUI continuously. I used PtMultiText widget for this purpose. But when i run the program continuously, the application becomes hangs. PtMultiTextModifyText() API is used to send logs to GUI.
Is there any method to know whether the PtMultiTextModifyText() has successfully updated the GUI. I have ensured that PtEnter() and PtLeave() calls are used correctly.
PtEnter()/PtLeave() code snippet used
int flags = PtEnter(0);
if ((flags >= 0) || (flags == -EDEADLK))
{
some GUI updates
if (flags >= 0)
{
PtLeave(flags);
}
}
We’d need to see/know more about the other threads and what happens in the ‘GUI Updates’ code.
For example if in the ‘GUI updates’ code, it attempts to acquire a different mutex that is held by one of the other GUI threads that is itself blocked on the PtEnter() call you’ve got a system deadlock.
Another possibility if you are writing in C++ is that an exception was thrown in the ‘GUI Updates’ code and kicked you out of the PtEnter block in which case you’d never hit the PtLeave call.
There are probably other possibilities. Hence the need to see the code or know more about your GUI threads.