Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import queue
- def printhi():
- print('Printed from child thread:',threading.current_thread().name)
- print('')
- #print('Printed from thread {}'.format(name))
- q = queue.Queue()
- #print(threading.current_thread())
- parent_thread = threading.current_thread()
- print('Name is:',parent_thread.name)
- #q.put(parent_thread)
- count = 0
- for i in range(5):
- q.put(threading.Thread(target = printhi,name='Thread {}'.format(count+1)),block=False)
- count += 1
- print('About to execute all the child threads:')
- while not q.empty():
- (q.get()).start()
- print('Size of queue now is:',q.qsize())
Add Comment
Please, Sign In to add comment