View Full Version : thread and fork()

11-11-2003, 10:11 AM
what's different between thread and fork( ) (or vfork( )) and their usage for programming in real life?
which one could be used in which situation?
I did read several posts, but still not clear.


jim mcnamara
11-11-2003, 01:34 PM
A process is a container for execution one or more threads. A process has to have at least one execution thread.

fork() creates a process out of the old process, bringing along all of the threads. It takes a snapshot of all the variables, program counter, etc, and creates a new process with the same
program counter, data, and code set. The forked process has a new process context, outside of the old one.

A new thread remains inside the process context.