php - 线程安全在 PHP 上下文中意味着什么?

标签 php thread-safety

<分区>

Possible Duplicate:
What is thread safe or non thread safe in PHP

什么是线程安全的或不是线程安全的?

例如,PHP 中的 setlocale() 不是线程安全的:

The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS or Apache on Windows, you may experience sudden changes in locale settings while a script is running, though the script itself never called setlocale(). This happens due to other scripts running in different threads of the same process at the same time, changing the process-wide locale using setlocale().

http://php.net/manual/en/function.setlocale.php

这实际上意味着什么?线程安全与否是好事吗?

在什么情况下您需要线程安全或非线程安全的解决方案来解决您的问题?

最佳答案

线程安全是一件好事,这意味着虽然可能有多个并发线程,但它们以一种安全的方式相互通信,不会出现竞争条件、并发问题等。

Thread safety is a computer programming concept applicable in the context of multi-threaded programs. A piece of code is thread-safe if it only manipulates shared data structures in a thread-safe manner, which enables safe execution by multiple threads at the same time. There are various strategies for making thread-safe data structures.

Source .

关于php - 线程安全在 PHP 上下文中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8334123/

相关文章:

concurrency - Golang 并发数组访问

php - 动态表单——设置数据库的正确方法?

javascript - 访问 jQuery 文件中的 PHP session 变量

java - 在java中处理套接字

ruby-on-rails - 如何使用 puma(线程安全)在 Rails 应用程序上动态设置 tld_length

java - MySQL Connector/JDBC 线程安全吗?

java - SecureRandom 流具有多个线程的奇怪行为

php - 必须保持向后兼容性中断的身份验证器类的方法

php - cURL 返回 XML 或 JSON

php - 在动态 PHP 网站中使用 .htaccess 进行 301 重定向