たわいも無いサンプル
from threading import Thread class TempThread(Thread): def run(self): print('hoge1') print('hoge2') print('hoge3') #for i in range(1000): # pass print('hoge4') print('hoge5') print('hoge6') if __name__=='__main__': t = TempThread() t.start() for i in range(10): #print('a') if t.isAlive() == True: continue t = TempThread() t.start() t.join()
これの実行結果
hoge1
hoge2
hoge3
hoge4
hoge5
hoge6
と一回しか実行されないのが気になる。。
「for i in range(10):」の一行下のprint文コメントアウトを外すと何回か実行されるのだけど。
join文が無いならともかく、join文あるのに待ちが入ってない気が・・