-- 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.
I observe that:
-- Initially (that means when each thread is processing its first item) all 10 threads starts and proceeds normally -- However, second item onwards, only 2 from 10 threads progress. -- Since there are multiple network, I/O operations involved, I assume all threads should interleave and get some CPU time.
Could you please explain the behavior? Any pointers to documentation or previously asked question on stack would be helpful.
sysctl hw.ncpu (mac OS) hw.ncpu: 2
Regards,