初回コミット

This commit is contained in:
ry-yamafuji 2024-01-25 08:11:42 +09:00
commit 035d94aac7

23
timeSchedule.py Normal file
View File

@ -0,0 +1,23 @@
import threading
import time
class TaskScheduler:
def __init__(self):
self._thread = threading.Thread(target=self._run_task)
self._thread.start()
def _run_task(self):
while True:
print("Task is running...")
time.sleep(10)
# インスタンスを作成し、スレッドを起動
scheduler = TaskScheduler()
# インスタンスを破棄(しかしスレッドは続行)
# del scheduler
# メインスレッドは他の作業を続ける
for _ in range(5):
print("Main thread is working...")
time.sleep(1)