1

I have a query I need to pitch even for once . With this method , but this method did use a lot of CPU and slows the server .

 public function setRunningLevelsReadyToRun(){
    $interval=5; //seconds
    set_time_limit(0);        
    while(true) {
        $now=time();
        mysql_query("UPDATE `levels` SET status='running' WHERE 'NULL' not in (uid1,uid2,uid3,uid4) AND status = 'opened'") or die(mysql_error());
        sleep($interval-(time()-$now));
    }

}

I read this question but I want to run this method in separate thread.

Community
  • 1
  • 1
shirin
  • 129
  • 1
  • 9
  • 1
    Just use cron if you can. See also here http://stackoverflow.com/questions/318361/timed-tasks-cron-like-in-php – scope Apr 01 '16 at 17:01

0 Answers0