Possible Duplicate:
Does PHP have threading?
I found this: http://php.net/manual/en/function.pcntl-fork.php
But I can't tell if those are threads or processes, I'm confused. They use both words.
In case you have an alternate solution, this is what I need threads for: I want to create a real-time game using web sockets, and I thought of having a single process running in the background, that spawns one thread for each game (or room) on demand.
That's just a wrapper for the C fork() function. It creates processes, not threads. PHP does not support multithreading.
pcntl_fork
creates a new process. While the word "thread" is used in the documentation, "process" is much more prominent:
The pcntl_fork() function creates a child process that differs from the parent process only in its PID and PPID.
PHP does not support multithreading (and it cannot assume that the web server itself is multithreaded in general).
Finally, spawning a thread for each anything is a naive approach to scaling that does not scale beyond a certain not-so-late point. I suggest looking into alternate architectures.
* PHP does not support multithreading.