PHPackages                             zhgzhg/gphpthread - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. zhgzhg/gphpthread

ActiveLibrary[CLI &amp; Console](/categories/cli)

zhgzhg/gphpthread
=================

Generic PHP Threads library using only pure PHP

1.0.8(6mo ago)154.4k5MITPHPPHP &gt;=5.3CI passing

Since Oct 18Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/zhgzhg/GPhpThread)[ Packagist](https://packagist.org/packages/zhgzhg/gphpthread)[ Docs](https://github.com/zhgzhg/gphpthread)[ RSS](/packages/zhgzhg-gphpthread/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (10)Used By (0)

GPhpThread - Generic PHP Threads library
========================================

[](#gphpthread---generic-php-threads-library)

[![build status badge](https://github.com/zhgzhg/GPhpThread/actions/workflows/build.yml/badge.svg?branch=master "Build status")](https://github.com/zhgzhg/GPhpThread/actions/workflows/build.yml/badge.svg?branch=master)

A heavy threads library implementation written using only pure PHP. A fully functional component that might come in handy when the host system does not have PHP threads module installed and for some reason it cannot be installed (lack of privileges, legacy system, et cetera).

Features
--------

[](#features)

- OO thread creation and management ideology
- Thread execution control:
    - start
    - stop
    - join - blocking or non-blocking mode
    - pause
    - resume
    - sleep with interruption detection
- Thread priority and niceness control
- Support for thread exit codes
- Critical section for sharing data among the threads or for locking purposes
    - reliable containers
    - faster, unreliable containers
- Extensible and customizable
- Distributed under MIT license

Requirements/Dependencies
-------------------------

[](#requirementsdependencies)

- PHP version 5.3+
- PHP shell execution context
- PHP pcntl
- PHP POSIX
- OS Linux family

How To Use
----------

[](#how-to-use)

In essence you need to extend class GPhpThread and implement the abstract method run(). Here is an example:

```
