#encoding:utf8
import threading
import time
data = 0
def func(sleeptime):
global data
print threading.currentThread().getName()
time.sleep(sleeptime)
threads = []
for i in range(0,40):
t = threading.Thread(target=func,args=(i,))
threads.append(t)
num = 0
for t in threads:
t.start()
while True:
#判斷正在運行的線程數量,如果小於5則退出while循環,
#進入for循環啟動新的進程.否則就一直在while循環進入死循環
if(len(threading.enumerate()) < 5):
break
