Question about thread

Russell Blau russblau at hotmail.com
Fri Nov 19 16:38:43 CET 2004


"Valkyrie" <valkyrie at cuhk.edu.hk> wrote in message
news:1100875373.911763 at eng-ser6...
> 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,))

You may ask, but when I tried your code, here is what happened:

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 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,))
...
1960
836
232
2864
3692
>>> Received 0
Received 1
Received 2
Received 3
Received 4

Note that the numbers 1960, etc., appear to be the return values of the
thread.start_new_thread() function.


-- 
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.





More information about the Python-list mailing list