0

How to use monitors in PHP?

Cameron Skinner
  • 48,389
  • 2
  • 64
  • 82
albertopriore
  • 604
  • 2
  • 9
  • 35
  • 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 Answers3

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
  • 11,847
  • 1
  • 28
  • 33
1

PHP is single threaded so there is no need for synchronization.

Cameron Skinner
  • 48,389
  • 2
  • 64
  • 82
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
  • 57,554
  • 49
  • 122
  • 178
  • 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