# Advanced Thread

You can use Thread as a waiting task with the Async function.

```php
new Async(function() {
    $threads = [
        new MyThreadA(),
        new MyThreadB(),
        new MyThreadC()
    ];
    
    foreach ($threads as $thread) {
        $data = Async::await($thread->start());
        echo $data;
    }
});
```

Or

```php
$class = new TestThread();
$class->start()->then(function ($data) {
    echo "Thread finished: " . implode(", ", $data) . "\n";
})->catch(function (Throwable $e) {
    echo "Thread failed: " . $e->getMessage() . "\n";
})->finally(function () {
    echo "Thread finished\n";
});
```
