I'm new in multithreading, so the answer is probably very simple.
I'm trying to make two instances of one class and run them parallel. I've read that I can use class inheritance to do that.
class hello(threading.Thread):
def __init__(self,min,max):
threading.Thread.__init__(self)
time.sleep(max)
for i in range(1000):
print random.choice(range(min,max))
h = hello(3,5)
k = hello(0,3)
I've noticed that this does not work (the first outputs are numbers between 3 and 5)
Could you explain what am I doing wrong?
Is this inheritance dedicated to do something else?
EDIT: I want to run these two objects parallel so since the second object has smaller wait, it has to print those numbers sooner.
According to porglezomps comment, I've tried to change the code - add a method which prints those numbers but it prints it sequentially. The problem is still there.