Search code examples
cmultithreadingforkposix

Is fork process an example of Multi threading in C?


I have heard that programming languages like java have concept of multi threading .When i studied fork process in c language , i thought if it is an example of multi threading .


Solution

  • No, it isn't. C doesn't even know fork(), but I assume you're talking about the POSIX function fork(). This creates a new process, which runs completely isolated (with a few exceptions like it can inherit open file descriptors) from the parent process.

    For threading in C, have a look at the thread functions in C11. Unfortunately, the support for these isn't very widespread, but there's also the POSIX threading interface pthreads.