Created
July 31, 2017 16:01
-
-
Save kartikanand/7b5307cfd85af075a1eb787df9212f7d to your computer and use it in GitHub Desktop.
Python Bits - Using Threads - Threading example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import threading | |
| # we'll use a Python thread to call this function | |
| def foo(arg1): | |
| print(arg1) | |
| # using the below syntax you can create a Python thread | |
| # Note that we need to pass a tuple to args, therefore I've | |
| # added a comma(,) after the "3", don't forget that | |
| thread = threading.Target(target=foo, args=(3,)) | |
| # starting the thread is no-brainer | |
| thread.start() | |
| # wait for the thread to finish | |
| thread.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment