This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', TRUE); | |
ini_set('display_startup_errors', TRUE); | |
$threads = array(); | |
for($i = 1;$i <= 3; $i++){ | |
// 开启一个线程 | |
$threads[$i] = new Handler($i); | |
$threads[$i]->start(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CounterThread extends Thread { | |
public function run() { | |
for ($i = 0; $i < 10; $i++){ | |
echo "Main thread:".$i."\n"; | |
} | |
} | |
} | |
$firstThread = new CounterThread(); | |
for($i = 0;$i <20; $i++){ |
NewerOlder