depends on your actual use case,
for example, if you want to load data in the back ground,
than start the thread that loads the data, your GUI will continue what ever is does an not block
when finished this thread sets a atomic bool to true (which has been initialized to false of course, named done or so ...)
in you main loop you add an idle call that queries done, if done, thanks for the data, no problem that on other thread does something because the other thread is finished.
this is one possible use case,
|