Advertisement
Guest User

Untitled

a guest
Dec 7th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. from multiprocessing import Process
  2. from time import sleep
  3.  
  4.  
  5. class MyProcess(Process):
  6.     def run(self):
  7.         sleep(3)
  8.  
  9.  
  10. def main():
  11.     processes = []
  12.     for _ in range(5):
  13.         new_proc = MyProcess()
  14.         new_proc.start()
  15.         processes.append(new_proc)
  16.     print('started')
  17.     while any(map(MyProcess.is_alive, processes)):
  18.         sleep(0.01)
  19.     print('stopped')
  20.  
  21.  
  22. if __name__ == '__main__':
  23.     main()
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement