Over a million developers have joined DZone.

Simple Thread In Python

·
Taken from this article.


import time
import thread

def myfunc(string,sleeptime):
    while 1:
        print string
        time.sleep(sleeptime)

thread.start_new_thread(myfunc,("Thread No:1",2))
# Then do other things.
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}