标签:lock 并发 php ++ open txt pen fopen sleep
<?php
for($i = 0;$i < 20;$i++){
$fp = fopen(‘test.txt‘,‘r‘);
if(flock($fp,LOCK_EX)){
echo $i.PHP_EOL;
sleep(1);
flock($fp,LOCK_UN);
}
fclose($fp);
}
标签:lock 并发 php ++ open txt pen fopen sleep
原文地址:http://blog.51cto.com/12173069/2294026