Processes vs Threads

Processes are full programs.They have their own PID (process ID) and PEB (Process Environment Block).These are the main features of processes:

  • Processes can contain multiple threads.
  • If a process terminates, the associated threads do as well.

Threads are a concept similar to processes: they are also code in execution. However, the threads are executed within a process, and the threads of the process share resources among themselves, such as memory. These are the main features of threads:

  • Threads can only be associated with one Process.
  • Processes can continue after threads terminate (as long as there is at least one thread left).

Get Mastering Python for Networking and Security now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.