Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. #!/usr/local/bin/python3
  2. """
  3. Spyder Editor
  4.  
  5. This is a temporary script file.
  6. """
  7. from multiprocessing import Process
  8.  
  9. def threadFunction():
  10.     i=1
  11.     while (i > 0):
  12.         print(i)        
  13.         i += 1        
  14.        
  15. #def __main__():
  16. if __name__ == '__main__':
  17.     # Esegui codice
  18.     print('Main started')
  19.     thread = Process(target = threadFunction)
  20.     thread.start()
  21.     print('Thread started')
  22.     print('Waiting...')
  23.     thread.join(5)
  24.    
  25.     if(thread.is_alive()):
  26.         thread.terminate()
  27.         print('Processo killato')
  28.         input('Press enter to get out of here...')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement