Tell a new module,
This module provides an abstraction layer to us, our program still have to rely on a final settlement of multi-threaded and multi-process, but we do not consider the multi-process and multi-threaded implementation details, we passed python packaged components, and can quickly achieve multi-process multi-thread coding
When we address the needs, should be considered good or IO intensive multi-threaded or multi-process compute-intensive use. Provides a multi-threaded and multi-process implementation of this module actuators
001 examples:
Traversal accumulated and multiplied by a number (no practical significance, is merely an example)
(1) Import Module
(2) a list of definitions 1-10
(3) defined functions count, analog consuming operations
Then 1-10 are passed to the count,
Accumulated value,
Then return: the accumulated result over the digital transmission is multiplied
(4) definition of a function, the result of printing
(5) were compared in three ways
① single sequence execution: execution order
Define the start time
Run worker function
End Time
② multi-threaded version
③ multi-process version
(6) Comparative Results
① single sequence of 7.6 seconds
② multi-threaded 10 seconds, because the scene is computationally intensive, multi-thread management itself also takes time.
③ multi-process for compute-intensive, so the shortest time
002 Conclusion
IO -intensive multi-threaded, multi-process compute-intensive use