The script shows how to execute 4 processes simultaneously in Python by using the
multiprocessing module. In this script, shared variables are defined which can be modified by processes, a message queue is also defined which allows communication between processes.
Four processes defined in this script are:
- Finding of Fibonacci numbers
- Finding prime numbers
- Estimation of Pi
- Output of results from other processes
The function
getchar() is used in the main program, it can wait for key input from the console without requiring the user to press [Enter].
Reference
Python multiprocessing,
ctypes
Source Code
Here is the script.
A sample result of running this program is given below
No comments:
Post a Comment