tags: os process thread is_child_of: process
Thread
A thread is a sequence of instructions getting executed independently. A thread is a part of the big process running independently from the parent process.
Why do we need threads?
There are following reasons to use threads.
- Program having several IO, networks and any blocking operation holds the program execution and CPU remains idle. This leads to resources wastage. So, organizing the program using threads can resolve this issue.
- Threads are lightweight. These are easy to create and destroy. Threads don’t require much of the resources like parent.
- Operations require parent process resource sharing. Different process can’t be created for the same resource. However, threads can share same parent resource.
- Threads can help gaining performance if the program is composed of several blocking operations.
Threads complications
- Makes programming model complicated.
- If child processes get threads from parent, blocking thread