Python Threading Tutorials

(Note: This content was migrated from http://teyc.editthispage.com)

Python has a high level threading module, but there has never been much specific tutorials on how to use it.

Just to get you started, here’s a code example:


import thread

def background(param1, param2, param3):
    print "Background thread called with %r %r %r" % (param1, param2, param3)
    print "Thread ended"

thread.start_new_thread(background, ("a", "b", "c"))

# This is necessary as the background thread is still running when the main thread exits.
import time
time.sleep(2)
print "Main thread ended"

At the moment, the easiest path for anyone who wanted to play around with threading in Python has to first learn about threading through a Java tutorial and then figure out how it maps to Python threading classes.

If anyone has come across handy guides on python threading, would you please post a link here? Thanks.


About this entry