0
以下のコードセグメントでは、実行スレッド数を20スレッドに制限したいと思います。一度カウンタが20に達すると、新しいスレッドは作成されませんが、 "a"の値はdo_something()関数をトリガしません(これは配列のすべての "a"を考慮する必要があるためです) )。どんな助けでも大歓迎です。Pythonスレッド数の制限を許可
count = 0
for i in range(len(array_of_letters)):
if i == "a":
if count < 20:
count=+1
t = threading.Thread(target=do_something, args = (q,u))
print "new thread started : %s"%(str(threading.current_thread().ident))
t.start()
count=-1
あなたはおそらく 'count = 1 +'(これはちょうど 'count = 1'、' -'と同じです。 –