Threads creation optimization
This commit is contained in:
@ -10,11 +10,11 @@ class CountdownTimer(Thread):
|
||||
self.seconds = seconds
|
||||
self.stop_event = Event()
|
||||
self.callback = callback
|
||||
super().__init__()
|
||||
super().__init__(daemon=True)
|
||||
|
||||
def run(self) -> None:
|
||||
cnt = self.seconds
|
||||
while cnt > 0 and not self.stop_event.is_set():
|
||||
while cnt and not self.stop_event.is_set():
|
||||
cnt -= 1
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user