import threading
import time
class Eat(threading.Thread):
def __init__(self, surname):
self.counter = 0
self.surname = surname
threading.Thread.__init__(self)
def run(self):
while True:
print("Hello "+self.surname)
time.sleep(1)
self.counter += 1
print("Bye "+self.surname)
begin = Eat("Cheeseburger")
begin.start()
while begin.isAlive():
print("eating...")
While begin
is in process of "eating", I want to print "eating..." but it seems i'm stuck in an infinite loop even after 1 second. Why do I get stuck in an infinite loop?