We’ve seen how a program can fork a child process.The child process is initially
running its parent’s program, with its parent’s virtual memory, file descriptors, and so
on copied.The child process can modify its memory, close file descriptors, and the like
without affecting its parent, and vice versa.When a program creates another thread,
though, nothing is copied.The creating and the created thread share the same memory
space, file descriptors, and other system resources as the original. If one thread changes
the value of a variable, for instance, the other thread subsequently will see the modi-fied
value. Similarly, if one thread closes a file descriptor, other threads may not read
from or write to that file descriptor. Because a process and all its threads can be exe-cuting only one program at a time, if any thread inside a process calls one of the exec
functions, all the other threads are ended (the new program may, of course, create new
threads).