क्या कोई जानता है कि मैं थ्रेड से एक चर (या एक चर प्राप्त) कैसे भेज सकता हूं, इस कोड में वैश्विक चर का उपयोग किए बिना? यदि नहीं, तो मैं वैश्विक चर कैसे संचालित करूं? बस दोनों कक्षाओं से पहले इसे परिभाषित करें और रन फ़ंक्शन में वैश्विक परिभाषा का उपयोग करें?कक्षा धागे के बीच संदेश भेजना Python
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()
धन्यवाद
क्या मैं कक्षा के बाहर इन्हें परिभाषित करता हूं? –
आपको उनका उपयोग शुरू करने से पहले कतार बनाना चाहिए, इसलिए हां, थ्रेड क्लासेस के बाहर/पहले। –