# Example

Code:

```php
<?php

declare(ticks=1);

require_once __DIR__ . '/../../../vendor/autoload.php';

use vennv\vapm\Work;
use vennv\vapm\Worker;
use vennv\vapm\System;

System::time();

$work = new Work();

$work->add(function ($h) : string {
    $number = 0;
    for ($i = 0; $i < 20000; $i++) {
        $number += $i;
        echo $i . PHP_EOL;
    }
    return $h;
}, ["a"]);

$work->add(function () : string {
    // In this will work with thread.
    return 'Hello World! 2';
});

// use 1 thread
$worker = new Worker($work, ['threads' => 2]);

$worker->run(function (array $result, Worker $worker) : void {
    var_dump($result);
    System::timeEnd();
    $worker->done(); // This will void memory leaks
});
```

Output:

```
array(2) {
  [0]=>
  string(1) "a"
  [1]=>
  string(14) "Hello World! 2"
}
Time for Console: 1.5306611061096
```
