# The Thread class

(PECL pthreads >= 2.0.0)

## Introduction

When the start method of a Thread is invoked, the run method code will be executed in separate Thread, in parallel.

After the run method is executed the Thread will exit immediately, it will be joined with the creating Thread at the appropriate time.

Warning

Relying on the engine to determine when a Thread should join may cause undesirable behaviour; the programmer should be explicit, where possible.

## Class synopsis

class Thread extends Threaded implements Countable, Traversable, ArrayAccess {
/* Methods */
public function getCreatorId(): int
public static function getCurrentThread(): Thread
public static function getCurrentThreadId(): int
public function getThreadId(): int
public function isJoined(): bool
public function isStarted(): bool
public function join(): bool
public function start(int `$options` = ?): bool
/* Inherited methods */
public function Threaded::chunk(int `$size`, bool `$preserve`): array
public function Threaded::count(): int
public function Threaded::extend(string `$class`): bool
public function Threaded::isRunning(): bool
public function Threaded::isTerminated(): bool
public function Threaded::merge(mixed `$from`, bool `$overwrite` = ?): bool
public function Threaded::notify(): bool
public function Threaded::notifyOne(): bool
public function Threaded::pop(): bool
public function Threaded::run(): void
public function Threaded::shift(): mixed
public function Threaded::synchronized(Closure `$block`, mixed `...$args`): mixed
public function Threaded::wait(int `$timeout` = ?): bool
}

## Table of Contents

- Thread::getCreatorId — Identification
- Thread::getCurrentThread — Identification
- Thread::getCurrentThreadId — Identification
- Thread::getThreadId — Identification
- Thread::isJoined — State Detection
- Thread::isStarted — State Detection
- Thread::join — Synchronization
- Thread::start — Execution

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open