Skip to content

Instantly share code, notes, and snippets.

@kartikanand
Created July 31, 2017 16:01
Show Gist options
  • Select an option

  • Save kartikanand/7b5307cfd85af075a1eb787df9212f7d to your computer and use it in GitHub Desktop.

Select an option

Save kartikanand/7b5307cfd85af075a1eb787df9212f7d to your computer and use it in GitHub Desktop.
Python Bits - Using Threads - Threading example
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