I'm confused trying to understand multiprocessing and multithreading
so this code will create 5 threads for each element in the list? and if the list has a million items will this create a million threads? do threads have limits?
And how many threads will be created if I specify ThreadPoolExecutor(10) ? 5 or 10
import concurrent.futures
list = [1,2,3,4,5]
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.map(function, list)
and when it came to multiprocessing it's more confusing, for example, does this code run 5 processes each one on a different core? and what if the CPU has only 4 cores, where the last process runs?
import concurrent.futures
list = [1,2,3,4,5]
with concurrent.futures.ProcessPoolExecutor() as executor:
executor.map(function, list)
My goal is to process many folders ( thousands ) , read files inside each folder, and write data to a database