2024-09-27 07:27:40 发布
网友
如果我有一门课穿线。穿线我使用.start()
class hello(threading.Thread): def run(): print "hi" print "bye"
所以这是一个线程,但是当我想要在一个类中包含两个线程函数时?我该怎么做?你知道吗
因为使用.start()时,它在新线程中使用run函数。你知道吗
改用target属性作为Thread构造函数:
target
Thread
class twothreads: def t1(self): print "Hi" def t2(self): print "Bye" t = twothreads() threading.Thread(target=t.t1).start() threading.Thread(target=t.t2).start()
改用
target
属性作为Thread
构造函数:相关问题 更多 >
编程相关推荐