Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Working with Threads
- from __future__ import print_function #Compatibilidade func print python 2/3
- from threading import Thread
- from time import sleep
- import random
- #Target function
- def worker(tsleep):
- print ('worker ini', tsleep)
- sleep(tsleep)
- print ('worker fim', tsleep)
- t = Thread(target=worker, args=(random.randrange(10, 20),))
- t.start()
- while t.isAlive():
- sleep(1)
- print('waiting')
- print('end')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement