{"id":33999436,"url":"https://github.com/appserver-io/fhreads","last_synced_at":"2026-06-09T09:31:50.364Z","repository":{"id":62486428,"uuid":"57026610","full_name":"appserver-io/fhreads","owner":"appserver-io","description":"A PHP Userland threading library based on fhreads php extension","archived":false,"fork":false,"pushed_at":"2016-05-26T16:51:14.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-12-14T21:13:23.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appserver-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-25T08:53:38.000Z","updated_at":"2016-04-25T09:43:55.000Z","dependencies_parsed_at":"2022-11-02T10:15:53.321Z","dependency_job_id":null,"html_url":"https://github.com/appserver-io/fhreads","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/appserver-io/fhreads","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Ffhreads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Ffhreads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Ffhreads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Ffhreads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appserver-io","download_url":"https://codeload.github.com/appserver-io/fhreads/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Ffhreads/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34101065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-13T09:02:45.018Z","updated_at":"2026-06-09T09:31:50.359Z","avatar_url":"https://github.com/appserver-io.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fhreads\n\n## A PHP Userland threading library based on fhreads php extension\n\n## What is it?\n\nAn implementation of threading utilites as part of the language directly in the PHP userland based on our php ext fhreads.\n\n## How to use?\n\n\u003e This library is in early-stage development. Please use with caution.\n\nThis is a simple example how to use a shared data object as normal php object with a thread safe counter property.\n```php\n\u003c?php\n\nrequire_once 'vendor/autoloader.php';\n\nuse AppserverIo\\Fhreads\\Thread;\n\n// define counter thread class which counts the shared data objects counter property\nclass CounterThread extends Thread\n{\n    /**\n     * Constructor which refs the shared data object to this\n     * \n     * @param object $data\n     */\n    public function __construct($data)\n    {\n        $this-\u003edata = $data;\n    }\n    \n    public function run()\n    {\n        fhread_mutex_lock($this-\u003edata-\u003emutex);\n        ++$this-\u003edata-\u003ecounter;\n        $this-\u003edata-\u003e{$this-\u003egetThreadId()} = $this-\u003egetThreadId();\n        fhread_mutex_unlock($this-\u003edata-\u003emutex);\n    }\n}\n\n$data = new \\stdClass();\n$data-\u003emutex = fhread_mutex_init();\n$data-\u003ecounter = 0;\n\n$ths = array();\n$tMax = 10;\n\n// initiate threads\nfor ($i = 1; $i \u003c= $tMax; $i++) {\n    $ths[$i] = new CounterThread($data);\n}\n// start threads\nfor ($i = 1; $i \u003c= $tMax; $i++) {\n    $ths[$i]-\u003estart();\n}\n// wait for all thread to be finished by joining them\nfor ($i = 1; $i \u003c= $tMax; $i++) {\n    $ths[$i]-\u003ejoin();\n}\n\n// echo status\necho \"$tMax threads finished...\" . PHP_EOL;\n// dump shared data object\nvar_dump($data);\n// echo status\necho PHP_EOL . \"finished script!\" . PHP_EOL;\n```\n\nThis should give us an amazing output! :)\n```bash\n10 threads finished...\nobject(stdClass)#1 (12) {\n  [\"mutex\"]=\u003e\n  int(19463520)\n  [\"counter\"]=\u003e\n  int(10)\n  [\"139792551667456\"]=\u003e\n  int(139792551667456)\n  [\"139792533702400\"]=\u003e\n  int(139792533702400)\n  [\"139792506754816\"]=\u003e\n  int(139792506754816)\n  [\"139792488789760\"]=\u003e\n  int(139792488789760)\n  [\"139792515737344\"]=\u003e\n  int(139792515737344)\n  [\"139792524719872\"]=\u003e\n  int(139792524719872)\n  [\"139792479807232\"]=\u003e\n  int(139792479807232)\n  [\"139792560649984\"]=\u003e\n  int(139792560649984)\n  [\"139792542684928\"]=\u003e\n  int(139792542684928)\n  [\"139792497772288\"]=\u003e\n  int(139792497772288)\n}\n\nfinished script!\n```\n\nSee `examples` folder for more usage demonstration.\n\nMore documentation and examples comming...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappserver-io%2Ffhreads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappserver-io%2Ffhreads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappserver-io%2Ffhreads/lists"}