Question about thread

Peter Hickman peter at semantico.com
Fri Nov 19 10:48:37 EST 2004


Valkyrie wrote:
> Refering to the following codes I found, there is nothing displayed in the
> console, may I ask why?
> 
> def thrd(param): # the thread worker function
>     print "Received",param
> 
> import thread
> for i in range(5): # start five threads passing i to each one
>     thread.start_new_thread(thrd,(i,))
> 
> Thanks in advance

The problem with your script is that it will run too fast before it quits and
kills all the threads.

if you add

a = 0
for i in range(100000):
	a = a + 1

to the end you will see the output.



More information about the Python-list mailing list