fork download
  1. import time, threading
  2.  
  3. def fun():
  4. for i in range(5):
  5. time.sleep(1)
  6. print(i)
  7.  
  8. def main():
  9. thread = threading.Thread(target=fun)
  10. thread.start()
  11. thread.join()
  12. # A thread foi finalizada, fazer algo a partir daqui
  13. print("Thread finalizada")
  14.  
  15. main()
Success #stdin #stdout 0.01s 17064KB
stdin
Standard input is empty
stdout
0
1
2
3
4
Thread finalizada