import multiprocessing
import time
def sq(a):
for n in a:
time.sleep(0.2)
print('square '+str(n*n))
def cub(a):
for n in a:
time.sleep(0.2)
print('cube '+str(n*n*n))
if __name__ == "__main__":
arr=[2,3,4,5]
p1=multiprocessing.Process(target=sq,args=(arr,))
p2=multiprocessing.Process(target=cub,args=(arr,))
p1.start()
p2.start()
p1.join()
p2.join()
print('done')
Here I'm getting output only done but not the square and cube.
This is the code what I'm trying for multi-processing. I got the output in case of multi-threading as most of syntax is same but not in case of multi-processing.