I develop a cli thread with pthread but I have a problem:
My code bellow:
class workerThread extends Thread {
private $time;
public function __construct($i) {
$this->i = $i;
$this->time = time();
}
public function run() {
echo "Begin running...\n";
while (true) {
echo "[{$this->getThreadId()} : {$this->i}] ";
if ($this->time + 10 < time()) {
break;
}
usleep(1000000);
}
}
}
class AppTest_Controller_Main extends Core_Controller {
public function thread3Action() {
error_reporting(E_ALL);
echo "Start\n";
$worker = new workerThread(1024);
$worker->start();
}
}
run cli command on centos 6.5, php v5.5.33 zts with ptheads extension
php cli.php -r"AppTest/Main/thread3"
result
Segmentation fault
But I run test thread on a file outside MVC then it work And this code work in windows.
Please help me, thank all !