No threading.start_new_thread(), useful addition?

sturlamolden sturlamolden at
Thu Oct 8 13:18:55 CEST 2009

On 8 Okt, 09:17, Ulrich Eckhardt <eckha... at> wrote:

> I'm looking at the 'threading' module and see that other than the 'thread'
> module it doesn't have a simple function to start a new thread. Instead,
> you first have to instantiate a threading object and then start the new
> thread on it:
>   t = threading.Thread(target=my_function)
>   t.start()

One usually want to subclass threading.Thread instead of specifying a
target function.

class mythread(threading.Thread):

    def run():
        # whatever

t = mythread()

Also, you may want to set the daemon flag before starting the thread,
which is why the thread is created in a suspended state.

More information about the Python-list mailing list