first, to determine whether PHP is TS or NTS version by Phpinfo (); View the thread Safety item in it, this project is to see if it is thread safe, if yes: enabled, it should generally be TS version, otherwise it is NTS version.
second, according to PHP ts\nts version to select the corresponding pthreads version version of Windows
http://windows.php.net/downloads/pecl/releases/pthreads/0.1.0/
I PHP version is 5.4.17, so download Php_pthreads-0.1.0-5.4-ts-vc9-x86.zip file package, where 0.1.0 is represented as the current pthreads version number, 5.4 is the PHP version number, TS is previously judged PHP corresponding TS, NTS version, VS9 Representative is the visual Studio compiler compiler compiled, the last x86 represents a 32-bit version.
Third, install pthreads extensionUnzip the downloaded Php_pthreads-0.1.0-5.4-ts-vc9-x86.zip package to get the PthreadVC2.dll and Php_pthreads.dll files, put the Vc2 file in the Php.exe sibling directory, php_ The Pthreads.dll is placed in the extension directory. 1. Modify the php.ini file to add Extension=php_pthreads.dll
2. Modify Apache configuration file httpd.conf add LoadFile "X:/php5/pthreadvc2.dll"
3. Restart Apache Server
iv. Test pthreads extension
[PHP]View Plain copy print?
- <?php
- class asyncoperation extends Thread {
- Public function __construct ($arg) {
- $this->arg = $arg;
- }
-
- Public Function run () {
- if($this->arg) {
- printf ("Hello%s\n", $this->arg);
- }
- }
- }
- $thread = new asyncoperation ("World");
- if($thread->start ())
- $thread->join ();
- ?>
Run the above code to get "HelloWorld", it means the installation pthreads expansion success!
PHP installation pthreads multithreading extension tutorial [Windows Chapter]