[Python] Today is the fifth day of multi-tasking

    Multi-process and multi-threaded programming has been learned from the beginning has been not very skilled, usually the main program does not use the General Assembly, First down.

    Multi-process:, start method to start the process by Process class multiprocessing module creation process (or subprocess module), join the waiting process method ends. If different processes shared variables, use the Queue class will have to manage the process, use the underlying pipes and semaphores.

    Multithreading: Thread class to create a thread through multiprocessing module, similar to the specific methods and processes. You can also inherit of the Thread class. In the multi-thread, common access resource is called the critical resources for the critical resources to be controlled by lock Lock class, each thread to acquire the lock by competition in order to achieve read and write critical resources.

    + Threaded asynchronous I / O: coroutine known, it is a major trend. Wait for further study.

Guess you like

Origin www.cnblogs.com/junenatte/p/12173510.html