Multithreading
Geiger Ho
s997659 at ee.cuhk.edu.hk
Fri Jan 25 04:41:06 EST 2002
Hi all,
I have a script below which intends to have output: 0, 1, 2, 3, 4.
However what I get is 4, 4, 4, 4, 4. Why? How can I correct it?
------------------------------------------
from threading import Thread
class MyThread(Thread):
def __init__(self, num_t):
Thread.__init__(self)
MyThread.num = num_t
def run(self):
print MyThread.num
for i in range(5)
x = MyThread(i)
x.start()
------------------------------------------
Thanks in advance.
Regards,
Geiger
More information about the Python-list
mailing list