Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!/usr/local/bin/python3.5
  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. if __name__ == '__main__':
  16.     # Esegui codice
  17.     print('Main started')
  18.     thread = Process(target = threadFunction)
  19.     thread.start()
  20.     print('Thread started')
  21.     print('Waiting...')
  22.     thread.join(5)
  23.    
  24.     if(thread.is_alive()):
  25.         thread.terminate()
  26.         print('Processo killato')
  27.         input('Press enter to get out of here...')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement