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...")
在begin
“吃”的过程中,我想打印“吃...”,但似乎即使在 1 秒后我也陷入了无限循环。为什么我会陷入无限循环?