exec(threads)

JS scjuonline at web.de
Mon Oct 7 06:51:29 EDT 2002


Dear List,

could someone explain how threads are implemented in Python?
Following program gives me 5 new processes on Linux. (ps)
Windows and Solaris don't create new processes.

#!/usr/local/bin/python
import thread
import time

def func(num):
    time.sleep(20+num)
    print "I'm thread Nr. %d"%num

print "################################################"
for c in xrange(0,5):
    thread.start_new_thread(func,(c,))
i=raw_input()

thx, J






More information about the Python-list mailing list