Home  >  Article  >  Backend Development  >  php线程安全版和非线程安全版应该用哪个?

php线程安全版和非线程安全版应该用哪个?

WBOY
WBOYOriginal
2016-06-06 20:14:131224browse

php线程安全版和非线程安全版应该用哪个,它们分别的使用场景是什么?

回复内容:

php线程安全版和非线程安全版应该用哪个,它们分别的使用场景是什么?

PHP所推出的Thread Safe主要针对的是Windows下以IIS来运行PHP的情况,因为Windows中频繁申请进程开销较大,所以在Windows中要以多线程方式来运转PHP,这时候就需要Thread Safe版本。而在Linux系统下,PHP绝大多数情况下都以多进程方式运行,所以直接使用None Thread Safe即可。

如果是使用ISAPI的方式来运行PHP就必须用Thread Safe(线程安全)的版本;而用FastCGI模式运行PHP的话就没有必要用线程安全检查了,用None Thread Safe(NTS,非线程安全)的版本能够更好的提高效率。

原因:
http://astar.baidu.com/forum/forum.php?mod=viewthread&tid=366

如果有多线程,就用线程安全版;

如果只有一个线程,就用非线程安全版。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn