

PHP Dark Arts: Multi-Threading - vital101
http://www.re-cycledair.com/php-dark-arts-multi-threading-part-1

======
arthurschreiber
This is not about multi-threading in the sense of using threads in PHP, but is
instead about fork()'ing new php processes. This is called multi-process
programming.

~~~
vital101
True. Although each new process is a new thread of execution right?

~~~
scrame
No, threads and processes are different. Threads are pieces of concurrent
execution with a shared state from the containing process. Processes are
heavier pieces of execution, they have their own memory and state, get a
distinct PID.

fork() is a system level command that copies the current process wholesale,
and then gives a pointer back to the parent process. This is very different
than an interpreter managed green thread (ala ruby 1.8), or a true concurrent
in-process threading model (like JVM threads).

Basically, processes tend to be heavier-weight, but more isolated and secure,
where threads tend to be faster and can work with shared state without needing
to use IPC mechanisms.

Quick googling found this discussion:
[http://stackoverflow.com/questions/807506/threads-vs-
process...](http://stackoverflow.com/questions/807506/threads-vs-processes-in-
linux)

