将参数从主线程传递到新线程

Jun*_*ior 4 php multithreading pthreads parameter-passing

如何使用扩展名将参数从主线程传递到PHP中的新线程pthreads

与此类似的东西如何将参数传递给Java线程?只是在PHP中。

小智 5

从以下代码开始:

http://www.php.net/manual/zh/thread.start.php

<?php
class My extends Thread {
    public $data = "";
    public function run() {
        /** ... **/
    }
}
$my = new My();
$my->data = "something"; // Pass something to the Thread before you actually start it.
var_dump($my->start());
?>
Run Code Online (Sandbox Code Playgroud)