Threads :-
A process is an instance of a program that is being executed by one or many threads. It is the basic unit of execution in an operating system. A process can have multiple threads, each of which can run concurrently and independently within the process.
Threads are lightweight and independent units of execution that share the same memory space as the process they belong to. They can also communicate with other threads within the same process. Threads are useful for performing multiple tasks simultaneously within a process, such as handling multiple user inputs or performing background tasks while the main thread continues to execute.
There are several types of threads:-
Kernel-level threads: These threads are managed by the operating system's kernel and have direct access to system resources.
User-level threads: These threads are managed by user-level libraries and are not directly visible to the operating system. They are typically faster to create and destroy than kernel-level threads.
Hybrid threads: These threads are a combination of kernel-level and user-level threads, and are used by some operating systems to provide the benefits of both types of threads.
Green threads: These threads are a lightweight form of user-level threads that are scheduled by a library or runtime, rather than by the operating system.
Fibers: These are a type of user-level threads which are scheduled by the operating system, they are lightweight and less resource-intensive than kernel-level threads.
0 Comments