Skip to content

Concept of Thread

1. Introduction to Threads

A thread is the smallest unit of execution in a process. A process can have one or multiple threads running simultaneously.

💡 Why use threads?

  • Faster execution (lightweight compared to processes).
  • Efficient CPU utilization (multiple threads share the same process resources).
  • Improves multitasking & responsiveness (e.g., running animations while processing user input).

2. Process vs. Thread

FeatureProcessThread
DefinitionA program in executionA lightweight unit within a process
Resource SharingEach process has separate memory & resourcesThreads share memory & resources of the process
CommunicationInter-Process Communication (IPC) requiredEasier communication (shared memory)
Creation OverheadHigh (new process requires new memory & system resources)Low (threads use existing process memory)
ExampleRunning two different applicationsRunning multiple tasks in a web browser (loading, rendering, scrolling)

✔ Example:

  • Opening MS Word creates a process.
  • Spell check, saving files, and text formatting run as threads inside the MS Word process.

3. Types of Threads

📌 1. User-Level Threads (ULT)

✅ Managed by user-space libraries, not the OS.
✅ Faster context switching since the OS is not involved.
✅ If one thread blocks, all threads in the process block.

✔ Example: Java Threads, POSIX Threads (Pthreads)


📌 2. Kernel-Level Threads (KLT)

✅ Managed by the Operating System (OS).
✅ Slower than User-Level Threads due to OS involvement.
✅ Can use multi-core processors efficiently.

✔ Example: Windows, Linux kernel threads.


4. Multithreading Models

Multithreading models describe how user threads are mapped to kernel threads.

ModelDescriptionExample OS
Many-to-OneMultiple user threads map to one kernel thread.Solaris Green Threads
One-to-OneEach user thread maps to one kernel thread.Windows, Linux
Many-to-ManyMultiple user threads map to multiple kernel threads.Modern Linux, Solaris

5. Benefits of Threads

✔ Faster Execution – No need for full process creation.
✔ Better CPU Utilization – Multiple threads can run on multiple cores.
✔ Efficient Memory Use – Threads share memory, reducing overhead.
✔ Improved Performance – Parallel execution speeds up tasks.


6. Example of Threads in Real-Life Applications

✔ Web Browser (Chrome, Firefox)

  • One thread for UI Rendering
  • One thread for Page Loading
  • One thread for Downloading Files

✔ Text Editor (MS Word, Google Docs)

  • One thread for Typing Input
  • One thread for Auto-saving
  • One thread for Spell Check

✔ Video Games

  • One thread for Rendering Graphics
  • One thread for Handling Input
  • One thread for Game Physics

7. Conclusion

✔ Threads are lightweight execution units inside a process.
✔ They improve multitasking and CPU efficiency.
✔ User-Level Threads are faster, Kernel-Level Threads are more powerful.
✔ Multithreading is widely used in modern software like browsers, games, and OS kernels.