グローバル変数を使用せずに、このコードでthreadOneからthreadTwoに変数を(または変数を)送信する方法を知っている人はいますか?そうでない場合は、グローバル変数をどのように操作しますか?両方のクラスの前に定義し、実行関数でグローバル定義を使用するだけですか?クラススレッド間でメッセージを送信する
import threading
print "Press Escape to Quit"
class threadOne(threading.Thread): #I don't understand this or the next line
def run(self):
setup()
def setup():
print 'hello world - this is threadOne'
class threadTwo(threading.Thread):
def run(self):
print 'ran'
threadOne().start()
threadTwo().start()
おかげ
これらはクラス外で定義しますか? –
キューを使用する前にキューを作成する必要があります。 –