How to use monitors in PHP?
Asked
Active
Viewed 333 times
0
-
Related (and possible duplicate): [PHP mutual exclusion (mutex)](http://stackoverflow.com/questions/2921469/php-mutual-exclusion-mutex) – ircmaxell Jan 13 '11 at 16:13
3 Answers
3
I might be wrong but i thought that the server side model of execution of php is single threaded (aka no more than one thread). In fact i think this is one of reasons of PHP's success. If this is the case i doubt is relevant how do you use synchronization primitives in php.

Mihai Toader
- 12,041
- 1
- 29
- 33
0
PHP is single threaded, but if you want to have something like mutex between different processes and you use PHP5, you can simply use built-in session locking to achieve this. Just combine session_start and session_commit at correct places.

Milan Babuškov
- 59,775
- 49
- 126
- 179
-
Sessions are not meant to be a cross-process mutex. And they likely shouldn't be abused in such a manor. There are a few other alternatives, but Sessions are not one of them... – ircmaxell Jan 13 '11 at 16:13