# Question: Its running the functions in sequential rather than parallel. how do I make it run in parallel?
# In the code below, I had to:
# - use multiprocessing to create three separate processes.
# - Make each one wait a random number of seconds between one and five, print the current time, and then exit.
import multiprocessing,time,datetime,random
def process1():
t1 = random.randint(1,5)
print("Waiting for "+str(t1)+" seconds")
time.sleep(t1)
print(datetime.datetime.now())
start = time.time()
process11 = process1()
process12 = process1()
process13 = process1()
print(datetime.datetime.now())
if __name__=="__main__":
p1 = multiprocessing.Process(target=process11)
p2 = multiprocessing.Process(target=process12)
p3 = multiprocessing.Process(target=process13)
p1.start()
p2.start()
p3.start()
p1.join()
p2.join()
p3.join()
end = time.time()
print("It takes " +str(end-start)+" seconds")