Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #匯入 線呈
- import threading
- #匯入 時間
- import time
- class TimerClass(threading.Thread):
- #self 自身屬性 , Trhread 創建一個Thread , i 幾秒重新啟動 , target 任務
- def __init__(self,Tthread = threading.Thread,i=1,target =None):
- threading.Thread.__init__(self)
- self.i = i
- self.target = target
- self.event = threading.Event()
- #執行
- def run(self):
- while not self.event.is_set():
- self.target()
- self.event.wait(self.i)
- #停止
- def stop(self):
- self.event.set()
Add Comment
Please, Sign In to add comment