PHP installation pthreads multithreading extension tutorial [Windows Chapter]

Source: Internet
Author: User
Tags vc9

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?
  1. <?php
  2. class asyncoperation extends Thread {
  3. Public function __construct ($arg) {
  4. $this->arg = $arg;
  5.   }  
  6.   
  7. Public Function run () {
  8. if($this->arg) {
  9. printf ("Hello%s\n", $this->arg);
  10.     }  
  11.   }  
  12. }  
  13. $thread = new asyncoperation ("World");
  14. if($thread->start ())
  15. $thread->join ();
  16. ?>
Run the above code to get "HelloWorld", it means the installation pthreads expansion success!

PHP installation pthreads multithreading extension tutorial [Windows Chapter]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.