Threads creation optimization

This commit is contained in:
Eden Kirin
2023-03-30 21:13:54 +02:00
parent 059408242c
commit c9707c0523
5 changed files with 17 additions and 14 deletions

View File

@ -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)