PHP的线程安全与非线程安全
来源:互联网 发布:面试淘宝美工常见问题 编辑:程序博客网 时间:2024/04/30 05:50
什么是线程安全?
Thread Safety means that binary can work in a multithreaded webserver context, such as Apache 2 on Windows. Thread Safety works by creating a local storage copy in each thread, so that the data won’t collide with another thread.
线程安全就是能够在多线程环境下正常工作。这取决于web server在处理并行访问时是否用到多线程。
如何选择?
PHP手册给出答案:
If you choose to run PHP as a CGI binary, then you won’t need thread safety, because the binary is invoked at each request. For multithreaded webservers, such as IIS5 and IIS6, you should use the threaded version of PHP.
不论在什么平台、用什么web server,只要是用cgi/fastcgi方式运行PHP,都用非线性安全。
这意味着nginx必然配合非线程安全的PHP,IIS则要用线性安全的PHP。Apache有两种运行模式:如果用fastcgi模式,则配合非线性安全PHP,如果用LoadModule模式,则要用线性安全PHP。后者应该是大多数Apache使用者的选择。
参考资料:
- http://php.net/manual/en/faq.obtaining.php#faq.obtaining.threadsafety
- http://stackoverflow.com/questions/1623914/what-is-thread-safe-or-non-thread-safe-in-php
- http://stackoverflow.com/questions/7204758/php-thread-safe-and-non-thread-safe-for-windows
1 0
- PHP线程安全与非线程安全的区别
- PHP线程安全与非线程安全的区别
- PHP 线程安全与非线程安全版本的区别
- PHP非线程安全与线程安全版本的选择
- PHP线程安全与非线程安全的区别
- PHP的线程安全与非线程安全
- php线程安全版本与非线程安全版本
- PHP线程安全与非线程安全安装包选择
- php线程安全与非线程安全安装包选择
- 线程安全与非安全
- [PHP]PHP的线程安全与非线程(NTS)安全版本的区别
- PHP线程安全和非线程安全的区别
- 关于PHP线程安全和非线程安全的区别
- 关于PHP线程安全和非线程安全的区别
- 线程安全与非线程安全
- JAVA线程安全与非线程安全
- 线程安全与非线程安全
- 线程安全与非线程安全
- 多线程_同步的特点及好处和弊端
- android利用ViewPage和ImageView实现主界面导航
- 005
- JS初学者使用jQuery开发一款弹幕射击游戏
- Python初学list与tuple教程
- PHP的线程安全与非线程安全
- Strom学习00---Grouping
- 89:Best Time to Buy and Sell Stock
- h5 canvas绘制的时钟
- $.ajaxsetup全局设置,怎么用?
- 自动装箱和拆箱原理简析
- C++知识点23
- Markdown初级教程-入门1
- 实验三:跟踪分析Linux内核的启动过程