-- I launch 10 threads
-- Threads share Queue.Queue().
-- Each Thread gets an item from the Queue
-- Each thread communicates first with External WebServer
-- Processes Data coming from Ext. WebServer
-- Communicates with internal DB
-- Gets the next the item from Queue
-- It repeats until Queue finishes
-- At which point all threads are joined and main thread exits normally
-- In the code, in main thread I populate Queue.Queue() with 500 items
-- Then each thread gets the first item in the queue.
私はそれを観察します:
-- 最初に (つまり、各スレッドが最初の項目を処理しているときに) 10 個のスレッドすべてが開始され、正常に処理が続行されます。ただし、2 番目の項目以降は、10 個のスレッドのうち 2 個のみが処理されます。-- 複数のネットワーク I/O 操作が関係しているため、すべてのスレッドがインターリーブして CPU 時間を取得する必要があると思います。
動作を説明していただけますか?ドキュメントへのポインタまたはスタックに関する以前の質問は役に立ちます。
sysctl hw.ncpu (Mac OS) hw.ncpu: 2
よろしく、