can call a static class
This commit is contained in:
parent
50f1156b08
commit
39e2888801
16
example2.php
16
example2.php
|
@ -9,18 +9,22 @@ require_once("ThreadQueue.php");
|
|||
|
||||
|
||||
|
||||
// it is the function that will be called several times
|
||||
// function is a static method of a class
|
||||
|
||||
abstract class class1 {
|
||||
|
||||
static function parallel_task($arg){
|
||||
echo "task with parameter '$arg' starts\n";
|
||||
sleep( rand(2,5) ); // wait for random seconds
|
||||
echo "task with parameter '$arg' ENDS\n";
|
||||
}
|
||||
|
||||
function parallel_task($arg){
|
||||
echo "task with parameter '$arg' starts\n";
|
||||
sleep( rand(2,5) ); // wait for random seconds
|
||||
echo "task with parameter '$arg' ENDS\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// we want 3 jobs in parallel instead of the default 2
|
||||
$TQ = new ThreadQueue("parallel_task", 3);
|
||||
$TQ = new ThreadQueue("class1::parallel_task", 3);
|
||||
|
||||
|
||||
// add tasks
|
||||
|
|
Loading…
Reference in New Issue