Skip to content

Instantly share code, notes, and snippets.

@BassyKuo
Last active July 24, 2017 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BassyKuo/2f9ba7cc1ec728a2bf5f771f07a0127c to your computer and use it in GitHub Desktop.
Save BassyKuo/2f9ba7cc1ec728a2bf5f771f07a0127c to your computer and use it in GitHub Desktop.
hello_threading.py
#!/usr/bin/env python3
import threading
num_threads = 5
th = {}
def main():
for th_id in range(num_threads):
th[th_id] = threading.Thread(target=show, args=(th_id,))
th[th_id].start()
# --- [ Waiting for all threads
for th_id in range(num_threads):
th[th_id].join()
# --- [ After all threads done
print ('===THE END===')
def show(idx):
print ('Hello Thread-{}'.format(idx))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment