1. The overall difference:
A process is the basic unit that serves and allocates system resources, and threads are the basic units of tasks executing, smaller than processes.
Threads can be understood as lightweight processes, which means that threads and processes have similar running structures, such as their own stack space and their own variables. It also means that the thread is running at a smaller cost than the process.
The process has a separate address space, and the thread does not have a separate address space, and it shares the address space with the thread that is in the same process as it.
2. Some problems arising from the distinction
Advantages of Threads:
A, the generation of a thread overhead, do not need to be like the process of code snippets, data segments, stack segments, environment variables and so on, so many resources maintenance costs. At the same time, the switch on the thread is much more efficient than the process. Therefore, in the multitasking high frequency communication scene, many processes show a relatively large advantage.
b, because of the public address space, the communication between threads is not as cumbersome as interprocess communication and much more efficient.
C, through multithreading to achieve multitasking, can optimize the structure of the code, easy to understand the program.
Disadvantages of Threads:
A, multithreaded programs are less robust than multi-process programs because, as long as one thread hangs in a multithreaded program, the entire process is killed.
B, multithreading resources to operate when the need to be very careful to prevent the simultaneous operation of multithreading, where the need to lock, the use of locks need to be very careful, attention to lock the order, to avoid the occurrence of deadlock.
Thought so much for the moment.