Or simpler <pre><code> import threading def to_run(): # should not take arguments. ... # code to execute in the thread (can be a loop, ...) # it uses the same variables as in the main thread. new_thread = threading.Thread() # create a new thread object. new_thread.run = to_run new_thread.start() # the new thread is created and then is running. </code></pre>