PHPackages                             kingbes/thread - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kingbes/thread

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kingbes/thread
==============

Thread

v0.0.1(11mo ago)02MITCPHP &gt;=8.2

Since Jun 7Pushed 11mo agoCompare

[ Source](https://github.com/KingBes/php-thread)[ Packagist](https://packagist.org/packages/kingbes/thread)[ RSS](/packages/kingbes-thread/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-thread
==========

[](#php-thread)

php Thread composer package

PHP8.2+FFI\*NTStrueWindowstruecomposer
========

[](#composer)

```
composer require kingbes/thread
```

usage
=====

[](#usage)

```
use KingBes\Thread\Thread;

class A
{
    public function demo()
    {
        echo "is demo";
    }
}

$class_a = new A();
$a = 1;
// 实例化 线程类
$thread = new Thread();
var_dump("start");
// 执行任务1
$thread->spawn(function () use (&$a) {
    echo "spawned 1 start:" . date("Y-m-d H:i:s") . "\n";
    sleep(1);
    $a += 3;
    var_dump($a);
    echo "spawned 1 end:" . date("Y-m-d H:i:s") . "\n";
});
// 执行任务2
$thread->spawn(function () use (&$a) {
    echo "spawned 2 start:" . date("Y-m-d H:i:s") . "\n";
    sleep(9);
    echo "spawned 2 end:" . date("Y-m-d H:i:s") . "\n";
    $a += 2;
    var_dump($a);
});
// 执行任务3
$thread->spawn(function () use (&$a, $class_a) {
    echo "spawned 3 start:" . date("Y-m-d H:i:s") . "\n";
    sleep(5);
    $a--;
    echo "spawned 3 end:" . date("Y-m-d H:i:s") . "\n";
    $class_a->demo();
    echo "\n";
});
// 等待任务执行完毕
$thread->wait();
var_dump("res:" . $a);
var_dump("end");
```

```
string(5) "start"
spawned 1 start:2025-06-06 09:10:15
spawned 2 start:2025-06-06 09:10:15
spawned 3 start:2025-06-06 09:10:15
int(4)
spawned 1 end:2025-06-06 09:10:16
spawned 3 end:2025-06-06 09:10:20
is demo
spawned 2 end:2025-06-06 09:10:24
int(5)
string(5) "res:5"
string(3) "end"
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance51

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

346d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fb58545c720c65fc3a128dec9077ca1e63c7de006c8ffa6f2041636ad94d1d74?d=identicon)[KingBes](/maintainers/KingBes)

---

Top Contributors

[![KingBes](https://avatars.githubusercontent.com/u/48203677?v=4)](https://github.com/KingBes "KingBes (2 commits)")

---

Tags

threadThreadffi

### Embed Badge

![Health badge](/badges/kingbes-thread/health.svg)

```
[![Health](https://phpackages.com/badges/kingbes-thread/health.svg)](https://phpackages.com/packages/kingbes-thread)
```

###  Alternatives

[ffi/location

PHP library for determining the physical location of binaries

1339.8k7](/packages/ffi-location)[ffi/var-dumper

List of symfony/var-dumper casters with FFI support

2010.7k4](/packages/ffi-var-dumper)[serafim/ffi-sdl

SDL FFI bindings for the PHP language

314.6k3](/packages/serafim-ffi-sdl)[lifo/php-ipc

Simple PHP Inter Process Communication (IPC) library

285.5k](/packages/lifo-php-ipc)[symfony-bundles/fork

SymfonyBundles Fork Library

178.0k](/packages/symfony-bundles-fork)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
