OS

Thread

A thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler

advantage

  1. processes are typically independent, while threads exist as subsets of a process

  2. processes carry considerably more state information than threads, whereas multiple threads within a process share process state as well as memory and other resources

  3. processes have separate address spaces, whereas threads share their address space

  4. processes interact only through system-provided inter-process communication mechanisms

  5. context switching between threads in the same process is typically faster than context switching between processes

drawbacks

  1. Synchronization: Careless use of such primitives can lead to deadlocks, livelocks or races over a resources.

  2. Thread crashes a process: an illegal operation performed by a thread crashes the entire process

Last updated