using code from this site: http://www.saltycrane.com/blog/2008/09/simplistic-python-thread-example/
The code is
import time from threading import Thread def myfunc(i): print "sleeping 5 sec from thread %d" % i time.sleep(5) print "finished sleeping from thread %d" % i for i in range(10): t = Thread(target=myfunc, args=(i,)) t.start() and I get this output:
sleeping 5 sec from thread 0 sleeping 5 sec from thread 1 sleeping 5 sec from thread 2 sleeping 5 sec from thread 3 sleeping 5 sec from thread 4 sleeping 5 sec from thread 5 sleeping 5 sec from thread 6 sleeping 5 sec from thread 7 sleeping 5 sec from thread 8 sleeping 5 sec from thread 9 finished sleeping from thread 0 finished sleeping from thread 2 finished sleeping from thread 4 finished sleeping from thread 1finished sleeping from thread 6finished sleeping from thread 8 finished sleeping from thread 5finished sleeping from thread 7finished sleeping from thread 9 finished sleeping from thread 3 what going on here? I am ok with the threads not printing in order because this is possible, but why are they not printing on newlines at the end? I am using python 2.6 under windows xp