Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What´s up with multithreading in php 7

I have read that one of expected features of PHP 7 is native Multithreading (http://www.phpzag.com/php-7-expected-features-for-php-7/) but now it is not listed in list of features http://php.net/manual/en/migration70.new-features.php Do you know if it was fulfilled or not? I didn´t found any official statements.

like image 744
Michal Mäsiar Avatar asked Mar 29 '16 11:03

Michal Mäsiar


People also ask

Is multithreading possible in PHP?

PHP applications, undoubtedly work effectively with multithreading capabilities. Multithreading is something similar to multitasking, but it enables to process multiple jobs at one time, rather than on multiple processes.

Can multithreading improve performance?

The ultimate goal of multithreading is to increase the computing speed of a computer and thus also its performance. To this end, we try to optimize CPU usage. Rather than sticking with a process for a long time, even when it's waiting on data for example, the system quickly changes to the next task.

How do you do multithreading in PHP?

You can use the pthreads extension in PHP <= 7.4 to enable multithreading in PHP. However, if you are using PHP > 7.4 then it would be great to use the parallel extension. Both of the given extensions can be downloaded from the “PECL” library of extensions.


1 Answers

There is no native Multithreading in PHP7.

You can find the official changelog for PHP7 at http://php.net/ChangeLog-7.php. Anything not listed in there is not in PHP7 obviously.

To learn about the new features of PHP7 and differences to 5.6, consider reading the upgrade guide at http://php.net/migration70.

If you need threading in PHP, consider installing http://php.net/manual/en/book.pthreads.php

like image 64
Gordon Avatar answered Sep 30 '22 00:09

Gordon