Pythonバージョン:3.5.1
OS環境:Windows 7(32 bit)
ソースコード1「d.setDaemon(True)」は下記のようになった。
import threading import time import logging logging.basicConfig(level=logging.DEBUG,format='(%(threadName)-10s) %(message)s',) def daemon(): logging.debug('starting') time.sleep(2) logging.debug('exiting') d = threading.Thread(name='daemon', target=daemon) d.setDaemon(True) def non_daemon(): logging.debug('starting_non') logging.debug('exiting_non') t = threading.Thread(name='non-daemon', target=non_daemon) d.start() t.start()
ソースコード2「d.setDaemon(False)」は下記のようになった。
import threading import time import logging logging.basicConfig(level=logging.DEBUG,format='(%(threadName)-10s) %(message)s',) def daemon(): logging.debug('starting2') time.sleep(2) logging.debug('exiting2') d = threading.Thread(name='daemon', target=daemon) d.setDaemon(False) def non_daemon(): logging.debug('starting_non2') logging.debug('exiting_non2') t = threading.Thread(name='non-daemon', target=non_daemon) d.start() t.start()
>>d.setDaemon(True)とd.setDaemon(False)の実行結果はどうして?
※何かがあればここで書いてください。
以上です。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。