# L-12 MCS 507 Mon 18 Sep 2023 : multiprocess

"""
Basic illustration of the multiprocessing module.
"""

from multiprocessing import Process
import os
from time import sleep

def say_hello(name,t):
    """
    Process with name says hello.
    """
    print('hello from', name)
    print('parent process :', os.getppid())
    print('process id :', os.getpid())
    print(name, 'sleeps', t, 'seconds')
    sleep(t)
    print(name, 'wakes up')

pA = Process(target=say_hello, args = ('A',2,))
pB = Process(target=say_hello, args = ('B',1,))
pA.start(); pB.start()
print('waiting for processes to wake up...')
pA.join(); pB.join()
print('processes are done')
