3

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 php_pthreads.dll in php/ext and system32 folders and add extension=php_pthreads.dll to php.ini .I did all these works but I get that error again.php_pthreads.dll and pthreadVC2.dll version is 14

<?php
class exampleThread extends Thread
{
    var  $Mobile;
    var  $code;
    public function __construct($Mobile, $code)
    {
        $this->Mobile = $Mobile;
        $this->code = $code;
    }

    public function run()
    {

    }
};
?>
Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
zohreh
  • 1,055
  • 1
  • 9
  • 26

2 Answers2

0

The pthreads extension cannot be used in a web server environment. It is only available in the CLI.

Whatever you're trying to do, you'll need to come up with another way of doing it.

0

As stated in the answer from duskwuff, the pthreads extension cannot be used in a web server environment.

We were playing around for about 1 week and unfortunately had to realize that running it in the CLI version leads to too many issues once it becomes too complicated --> we stopped and removed pthreads from our environment.

What I can suggest you:
Due to the fact we still need a multi-threaded functionality we were checking several methods and ended up using curl multi functions.

With curl multi functions you achieve a full multi-threading execution - and especially in our case - when you got lot of cores [we have 48] you can indeed use all of them when you spawn your tasks with curl...

The PHP curl multi exec documentation is very poor. I refer to this thread where you get additional information.

Peter VARGA
  • 4,780
  • 3
  • 39
  • 75