from threading import *
from time import *
class MyThread(Thread):
def __init__(self,x):
self.x = x
Thread.__init__(self)
def run(self):
sleep(2)
print(self.x)
if __name__=='__main__':
threads = []
for i in range(5):
threads.append(MyThread('Hello'))
for i in range(5):
threads[i].start()
for i in range(5):
threads[i].join()
This code print 'Hello' 10 times but if I comment "sleep(2)" it prints 'Hello' 5 times.
What is the problems with sleep() function? OR Where is the problem?
I am using Python3000.