python多线程,执行第10个时退出了,为啥啊?
import threading
import time
def tpppppp(qqq):
print (threading.current_thread().name,threading.activeCount(),qqq)
time.sleep(1)
pppp=0
print (type(pppp))
print (threading.current_thread().getName())
while 1:
if threading.activeCount() <= 4:
pppp += 1
tt=threading.Thread(target = tpppppp,args = (str(pppp)))
tt.setDaemon(True)
tt.start()
tt.join()
=====输出如下,第10个就退出了=============
MainThread
Thread-1 2 1
Thread-2 2 2
Thread-3 2 3
Thread-4 2 4
Thread-5 2 5
Thread-6 2 6
Thread-7 2 7
Thread-8 2 8
Thread-9 2 9
Exception in thread Thread-10:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
TypeError: tpppppp() takes 1 positional argument but 2 were given
Exception in thread Thread-11:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
TypeError: tpppppp() takes 1 positional argument but 2 were given