is_alive()を使用して、Python3.2であるスレッドを別のスレッドからテストしようとしています。で使用するthread1().is_alive()
と、が実行されているかどうか の代わりにthread2
取得します。false
true
thread1
中に入れても同じ結果になりますが、thread1().is_alive()
中にthread1
入れる
と期待通りに戻ります。self.is_alive()
thread1
true
コマンドが必要であるかのように私には見えましたthread1.is_alive()
が、それは1つの引数が必要であり、失敗することを示しています。
単純なものが欠けているように感じますが、それが何であるかを見つけることができませんでした。
ポインタをいただければ幸いです、ありがとう
わかりました。テストコードは次のようになります。
import threading
import time
#
class FirstThread(threading.Thread):
def run (self):
while 1:
print ('This is the First thread')
print(self.is_alive())
time.sleep(1)
FirstThread().start()
#
class TestThread (threading.Thread):
def run ( self ):
while 1:
print ('This is the thread alive test thread')
print(FirstThread().is_alive())
time.sleep(1)
TestThread().start()