线程由它自己启动

时间:2016-03-19 02:54:16

标签: python-3.x

a = Thread(target=main_programm(1, int(maximum/4)))
a.daemon = True
b = Thread(target=main_programm(int(maximum/4), int(maximum/3)))
b.daemon = True
c = Thread(target=main_programm(int(maximum/3), int(maximum/2)))
c.daemon = True
d = Thread(target=main_programm(int(maximum/2), maximum))
d.daemon = True


print("Done!")
#------------end of programm------------#

所有线程都在运行,甚至没有启动它们;( 不知道为什么这是幸福的 希望你能帮助我

1 个答案:

答案 0 :(得分:0)

不是传递函数,而是运行它。将参数传递为使用args关键字,如此。

a = Thread(target=main_programm, args=(1, int(maximum/4)))
a.daemon = True
b = Thread(target=main_programm, args=(int(maximum/4), int(maximum/3)))
b.daemon = True
c = Thread(target=main_programm, args=(int(maximum/3), int(maximum/2)))
c.daemon = True
d = Thread(target=main_programm, args=(int(maximum/2), maximum))
d.daemon = True

a.start()
b.start()
c.start()
d.start()

print("Done!")
#------------end of programm------------#