0
import time
import threading
def do_something():
while True:
time.sleep(0.5)
print('I am alive')
def main():
while True:
time.sleep(1)
print('Hello')
daemon_thread = threading.Thread(target=do_something, daemon=True)
daemon_thread.start()
main()
daemon_thread
をdo_something()
の外側から3秒間スリープさせる方法はありますか?私はdaemon_thread.sleep(3)
のような仮説を意味しますか?スレッドの外側からスレッドをスリープ状態にする方法はありますか?
あなたは[ 'queue']を使用することができます(https://docs.python.org/3/library/ queue.html)を使用してスリープコマンドをスレッドに通知します。 –
@LutzHorn新しいアカウントを作成しましたか? – Maroun
@MarounMaroun? –