This recipe will show us how to start a thread. It will also demonstrate why threads are necessary to keep our GUI responsive during long-running tasks.
Starting a thread
Getting ready
Let's first see what happens when we call a function or a method of our GUI that has sleep associated with it without using threads.
We are using sleep here to simulate a real-world application that might have to wait for a web server or database to respond, a large file transfer, or complex computations to complete its task. sleep is a very realistic placeholder and shows the principle involved.