Skip to main content

Command Palette

Search for a command to run...

What is the difference between Process and Thread?

Published
2 min readView as Markdown
What is the difference between Process and Thread?
C
酷愛計算機技術Ardently Love Computer Technology 長期關註反洗錢反欺詐Long-term Focus on Anti-Money Laundering and Anti-Fraud 精通支付結算的技術、系統、流程和製度Proficient in the Technology, System, Process and Institution of Payment and Settlement

To better understand this question, let’s first take a look at what is a Program. A Program is an executable file containing a set of instructions and passively stored on disk. One program can have multiple processes. For example, the Chrome browser creates a different process for every single tab.

A Process means a program is in execution. When a program is loaded into the memory and becomes active, the program becomes a process. The process requires some essential resources such as registers, program counter, and stack.

A Thread is the smallest unit of execution within a process. The following process explains the relationship between program, process, and thread.

  1. The program contains a set of instructions.

  2. The program is loaded into memory. It becomes one or more running processes.

  3. When a process starts, it is assigned memory and resources. A process can have one or more threads. For example, in the Microsoft Word app, a thread might be responsible for spelling checking and the other thread for inserting text into the doc.

Main differences between process and thread:

  1. Processes are usually independent, while threads exist as subsets of a process.

  2. Each process has its own memory space. Threads that belong to the same process share the same memory.

  3. A process is a heavyweight operation. It takes more time to create and terminate.

  4. Context switching is more expensive between processes.

  5. Inter-thread communication is faster for threads.


More from this blog

Penetration Test、Python、Weaponization

721 posts

微信 smartcat9999 反欺詐Anti-Fraud 反洗錢Anti-Money Laundering 反逃稅Anti-Tax Evasion 滲透測試Penetration Test 武器化Weaponization