我有一个类线程是这样的:多线程参数路过
import threading, time
class th(threading.Thread):
def run(self):
print "Hi"
time.sleep(5)
print "Bye"
现在让我们说,我想“沉睡”不同的每一次,所以我尝试:
import treading, time
class th(threading.Thread, n):
def run(self):
print "Hi"
time.sleep(n)
print "Bye"
它不工作,它给我留言:
组参数必须是无,现在
那么,如何在运行中传递参数?
注:我在班上像另一个函数做的:
import treading, time
class th(threading.Thread):
def run(self):
print "Hi"
time.sleep(self.n)
print "Bye"
def get_param(self, n):
self.n = n
var = th()
var.get_param(10)
var.start()
'selfn'应该是'self.n'。 – user2357112
谢谢。我没有考虑它,这非常有帮助。 –