Threading tips and caveats
The previous example may have made multithreaded programming seem simple, but that's because the code was carefully designed to avoid some of the problems that can arise when working with threads. In reality, retrofitting multithreading on a single-threaded application can be much more difficult.
One common problem is when a worker object gets stuck in the main thread, causing us to lose the benefits of multithreading. This can happen in a few ways.
For example, in our original threading script (the one that used moveToThread()), we had to move the worker to the thread before connecting any signals. If you try moving the threading code after the signal connections, you will find that the GUI locks up as though you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access