Can I use a dummy lock file for PHP to implement mutual exclusion?

时间:2016-04-21 22:50:20

标签: php concurrency locking mutual-exclusion

I was wondering whether this is a good way to implement mutual exclusion on PHP: You use PHP flock() and a dummy lock file.

Because flock() only allows one process to access a file.

$file = fopen("dummyLockFile");
flock($file, LOCK_EX)
//Critical section
fflock($file, LOCK_UN)
fclose($file)

0 个答案:

没有答案