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()
    {

    }
};
?>
5
  • Show your code. Commented Nov 23, 2017 at 5:35
  • @urfusion I edited Commented Nov 23, 2017 at 5:37
  • stackoverflow.com/questions/22901578/… Commented Nov 23, 2017 at 5:38
  • @urfusion Not a duplicate. The situation has changed significantly since PHP 5.5. Commented Nov 23, 2017 at 5:48
  • @duskwuff : I has not raise a duplicate flag. It just for reference. :) Commented Nov 23, 2017 at 5:50

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.