3 ms·
A lot of the time, you can set up your shared state ahead of time and then fork. Still likely more overhead than just creating a thread, but not as much as an
by moonchild 6y ago
A lot of the time, you can set up your shared state ahead of time and then fork. Still likely more overhead than just creating a thread, but not as much as an exec.
Ultimately, the question of how (and when) to parallelize is very domain- and problem-specific. Multithreading, multiprocessing, coroutines, and xargs -P will all be the right solution sometimes.