pthreads is an Object Orientated API that allows user-land multi-threading in PHP. It includes all the tools you need to create multi-threaded applications targeted at the Web or the Console. PHP applications can create, read, write, execute and synchronize with Threads, Workers and Threaded objects.
Questions tagged [php-pthread]
35 questions
4
votes
1 answer
Unable to load dynamic library 'C:\php\ext\php_pthreads.dll'
I'm trying to have threads in my php code, but I can't get my head around pthreads library and every time I run my program I encounter this error:
Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pthreads.dll' - The specified…

HessamSH
- 357
- 1
- 5
- 18
4
votes
0 answers
Sleep() in Thread PHP
I have a PHP script where I create several threads with the pthread library. In these threads I use the sleep() function. The problem is that sleep() pause my main thread. So I lose all the advantage of making threads...
Does anyone have a way to…

Hcetipe
- 466
- 2
- 10
4
votes
1 answer
Yii Framework Context in PHP Pthread Class
I'm working on PHP Pthreads. I have written a class which inherits the "Thread" class. This class does not recognize the Yii (1.x) framework context. I cannot use any of the Yii framework components or models. I have made sure the thread class…

Arfeen
- 2,553
- 5
- 29
- 48
3
votes
3 answers
race condition in PHP using pthreads
I have small code that demonstrate how to perform a race condition in multithreads PHP.
The idea is I and my friend is sharing the pot for cooking. if the pot already have ingredient, so the pot can not cook.
class Pot:
class Pot
{
public $id;
…

Erics Nguyen
- 370
- 4
- 16
3
votes
1 answer
What is the parallel extension in PHP and how do I use it?
I have been trying to use threads in PHP for my application but could not find a supporting DLL for Windows for PHP VC15 7.4. When I was looking for more details and tutorials on threads in PHP, I found that the PHP Documentation is pointing to use…

Airy
- 5,484
- 7
- 53
- 78
3
votes
2 answers
php why I get Class 'Thread' not found
I am using php version 7 and defined a class that extend Thread class but when I run My Program that give me Class 'Thread' not found error.I searched and I found out I must copy pthreadVC2.dll in apache and system32 folders and copy…

zohreh
- 1,055
- 1
- 9
- 26
3
votes
0 answers
PHP Pthread pool management
(First problem is below)
Finally made it like i wanted ! What a headache ^^
Not using pool was the answer ;)
So, here is my code, output below !
As you can see on the output, i got my jobs distribute evenly between workers 1 & 2 while worker 0 is…

Oshydaka
- 31
- 3
3
votes
1 answer
Drawbacks or side-effects when compiling PHP with --enable-maintainer-zts (to use php pthread)
I have a web application and is running fine with PHP 5.5.5 on a production environment.
On the same server now I need to run some PHP scripts that make use of php pthread (v. 2.0.10)
Is it safe to rebuild php with --enable-maintainer-zts (to allow…

Paolo
- 15,233
- 27
- 70
- 91
2
votes
1 answer
Using pthreads POSIX library within a PHP extension seemingly halting all execution
I'm trying to write and run a PHP extension that spins off a pthread (using the POSIX library in C) which detaches and runs forever (it reads messages from a queue, but for the purposes of this question that isn't important, and I'm just trying to…

KeithDeSantis
- 21
- 2
2
votes
0 answers
What is the purpose of the Socket class within the pthreads extension for PHP
The pthreads extension for PHP has an undocumented socket class appropriately named 'Socket'. The extension's examples folder has at least one example that uses the Socket class, but other than that (and surfing the extension's C code) one wouldn't…

JSON
- 1,819
- 20
- 27
2
votes
1 answer
How to multi-thread with pThreads in PHP7? workers, pool, etc
I am currently wanting to learn and implement pthreads - github. I have compiled php7 with the necessary components and verified that thread-safety is enabled. My current example code has 4 child classes that belong to parent class Canine. How…

Code_Ed_Student
- 1,180
- 6
- 27
- 67
1
vote
1 answer
PHP Curl Reuse In Thread
i wanted perform curl reuse in thread like here : PHP Curl Reuse Optimization
but when i executed this code :
//main code
$n=0;
$app = [];
$app_default = new WebRequest();
for ($n = 0; $n < 50; $n++){
$app[$n] = $app_default;
$app[$n] ->…

ehsan
- 29
- 1
- 6
1
vote
1 answer
PHP parallel how to pass variable to thread?
i use the Parallel PHP library, but i don't know how to pass variable of my script to a parallel thread. I view in the documentation that i must pass a array argument in the "run" function but i don't know how to access to the argument value.
My…

Errorj404
- 43
- 8
1
vote
0 answers
PHP segfault - how to get php file and line number?
I have a big application, running in multithreaded mode - 45 threads.
At some point the application crashes with Segmentation fault. I use gdb by the next way:
ulimit -c unlimited
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t
sleep 10 &…

Mikael
- 1,209
- 1
- 16
- 47
1
vote
0 answers
Why socket in object sets to 0
I'm creating a multithreaded server, and i've stucked on this problem. To accept and handle connections i'm using socket_accept, and then creating a Connection object, adding it to array, and then fetching through all array. But for some reason,…

Yexeed
- 33
- 3