A Thread is the basic unit of CPU utilization; it comprises a thread ID, a program counter, a register set, and a stack. It is sometimes called a lightweight process.
Traditional processes have a single thread of control. However, modern applications are heavily multithreaded. For example, a web browser might have one thread display images while another thread fetches data from the network.
If a web server used a heavy-weight process for every incoming request, it would consume massive amounts of memory and CPU cycles just creating and destroying those processes.
Threads within the same process share:
Because they share memory, threads are incredibly fast to create, fast to destroy, and extremely fast to switch between (context switching a thread is much cheaper than context switching a process).
User-level threads are implemented by a thread library at the user level, entirely independent of the operating system kernel. The kernel is completely unaware of these threads.
Kernel-level threads are supported and managed directly by the operating system kernel. Windows, Linux, and macOS all use kernel-level threads.
How are user threads mapped to kernel threads?