# 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

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

## Table of Contents

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