python threads threading

Threads in Python

Current Status
Not Enrolled
Price
$1.99
Get Started

A thread is often also referred to as a lightweight process. In general, a thread in computer science refers to an execution thread or an execution sequence in the execution of a program.

By default, each process has at least one thread, in a sense the process itself. A process can start several threads. The operating system executes these seemingly simultaneously, just like processes.

The advantage of threads over processes is that the threads of a process share the same memory area for global variables. If a thread changes a global variable, the new value is also immediately visible in this variable for all other threads of the process. Other advantages are that on a system with multiple CPU cores, the program can be executed much faster because the threads can actually be executed simultaneously by the processes. In addition, the program can always remain responsive on both single-core and multi-core systems. However, a thread also has its own local variables.

The management of threads is easier for the operating system, which is why threads are also called lightweight processes