This is untrue.
This is only true for Win32, where the fork() call doesn't even really exists (it's poorly faked using threads), on every other platform fork() costs almost the same, and provides many valuable additional benefits (like better memory protection, better management etc etc)
Not to mention, he's spawning only 5 (count'em - five) processes, what would be cummulative gain on that, even on win32?
| [reply] [Watch: Dir/Any] |
I agree that there is no difference if you would create as many threads as forked processes. The difference is that you need to call fork once for every planned task - whereas in a thread model you can share data and thus you would start threads only 5 times depending on the number of workers as the workers can get the data from a queue instead of a function parameter.
| [reply] [Watch: Dir/Any] |
In the OP case, where the final intend is to run an external command, the optimum solution would probably be to fork a new process and exec the command.
| [reply] [Watch: Dir/Any] |