TL;DR: If I spawn 10 web requests, each on its own thread, with a CPU that has a 4 thread limit, is this okay or inefficient? Threads are IO bound so sit idle while awaiting server response (I believe). How does CPU deal if more than 4 threads return simultaneously?
I've got a script that currently starts a new thread for every file I need to download (each located at a unique URL) through an http.client.HTTPSConnection. At max, I may need to spawn 730 threads. I have done this, since the threads are all IO bound work (downloading and saving to file), but I am not sure if they are executing in parallel or if the CPU is only executing a set at a time. Total run time for file sizes ranging between 20MB to 110MB was roughly 15 minutes.
My CPU is quad-core with no Hyper-Threading. This means that it should only support 4 threads simultaneously at any given time. Since the work is IO bound and not CPU bound, am I still limited by the hold of only 4 simultaneous threads?
I suppose what is confusing is I am not sure what sequence of events takes place if say I send out just 1 request on 10 threads; what happens if they all return at the same time? Or how does the CPU choose which 4 to finish before moving onto the next available thread?
And after all of this, if the CPU is only handling 4 threads at a time, I would image it is still smart to spawn as many IO threads as I need (since they will sit idle while waiting for server response) right?