Member-only story
Linux — Threads
Why do we need threads?
In fact, for any process, even if we do not actively create threads, the process by default has a main thread. A thread is responsible for executing binary instructions, following the project execution plan step by step. A process, however, manages much more than just executing instructions — it also handles memory, the file system, and more.
So, a process is like a project, while threads are the individual development tasks created to fulfill the project requirements. By default, you can set up one large task, assign it to a single person, and have them complete it from start to finish — this is the main thread. However, sometimes you may find that the task can be broken down. If the subtasks are not highly dependent on each other in a sequential manner, they can be executed in parallel.
For example, if you receive a development task to create 200 pages for a website, you can break it down into 20 tasks, each handling 10 pages, and develop them in parallel. Once all the pages are completed, you can integrate them together. This approach is certainly much faster than developing all 200 pages sequentially.
