I have been fascinated by multi-threaded programs for a few years, and have never quite grasped the power of concurrency during the day of my studies at various schools. My understading of how concurrency function is by no means affluent, but my knowledge will grow in the coming weeks. In my endaevour to construct a simple application with concurrency in mind was my focus in today's topic.
With my fascination with this subject matter, i shall continue with some concurrency code.
I want to pose two important questions, which i have yet to understand:
1) How does one explain a process is running multiple threads in a program ?
2) How does one explain multiple processes are running in a program with one thread per process ?
How does a process definied itself ? A process is defined as a program being run in memory which generates a process ID, this main process will fork other processes accordingly. In accordance with a typical Linux OS, by running this command: python genLottoNum.py, the main process will ultimately be python itself residing in memory. The sub-process which it depends upon will be the file that is running in memory. One can see a process running "ps auxf". A thead is more like a sub-process where even when running the command above would not allow a user to see a running thread.
Those were the core questions i woud like to pose, which i have yet to figure out in code. My sample program will answer either Q1 or Q2.
In my sample code, i have two threads randomly generating values, which is done via a pseudo-random number generator to produce numbers in the form of a lottory ticket.
while a < 6:
num = genLotto()
# handling Threading processes
t1 = threading.Thread(name="m5", target=genLotto)
t1 = threading.Thread(name="m5", target=prtLottoNum)
t2 = threading.Thread(name="m6", target=genLotto)
t2 = threading.Thread(name="m6", target=prtLottoNum)
# starting the threading processes
# this code will allow to work in windows and better in *nix