Class threading

# pht\Thread::addClassTask

(PECL pht >= 0.0.1)

pht\Thread::addClassTask — Class threading

### 説明

public pht\Thread::addClassTask ( string `$className` [, mixed `$...ctorArgs` ] ) : void

Adds a new class task to a pht\Threads internal task queue.

### パラメータ

`className`

  The name of the class to be threaded. This class must implement the pht\Runnable interface.

`...ctorArgs`

  An optional list of arguments for the threaded class' constructor. These arguments will be serialised (since they are being passed to another thread).

### 返り値

No return value.

### 例

例1 Adding a new class task to a thread

`<?php
use pht\{Thread, Runnable};
class Task implements Runnable
{
private $one;
public function __construct(int $one)
{
$this->one = $one;
}
public function run()
{
var_dump($this->one);
}
}
$thread = new Thread();
$thread->addClassTask(Task::class, 1);
$thread->start();
$thread->join();`

上の例の出力は以下となります。

    int(1)