- Thread Concept:
- Each program that is running on the system is a process. Each process contains one or more threads. A process can also be a dynamic execution of an entire program or part of a program. A thread is a set of instructions, or a special section of a program that can be executed independently in a program. It can also be understood as the context in which the code runs. So a thread is basically a lightweight process that is responsible for multitasking in a single program. Typically, the operating system is responsible for scheduling and executing multiple threads.
- A thread is a single sequential control flow in a program. Running multiple threads at the same time in a single program accomplishes different tasks, called multithreading.
- The difference between a thread and a process is that the child process and the parent process have different code and data spaces, while multiple threads share the data space, and each thread has its own execution stack and program counter for its execution context. Multithreading is mainly to save CPU time, play use, depending on the situation. The running of a thread requires the use of the computer's memory resources and CPU.
- The concept of multithreading
- Multithreading refers to the technique of implementing concurrent execution of multiple threads from software or hardware.
- Multithreading is to accomplish many tasks synchronously, not to improve the efficiency of the operation, but to improve the efficiency of the use of resources to improve the efficiency of the system. Threads are implemented at the same time when multiple tasks need to be completed.
- The simplest analogy is that multithreading is like every carriage of a train, while a process is a train. It is impossible to run without a train, and the train cannot have only one compartment. The advent of multithreading is to improve efficiency.
What is multithreading? What is a lock? What is the amount of information? and their usefulness