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

本问题已经有最佳答案,请猛点这里访问。

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

这实际上意味着什么?有没有什么东西是线程安全的?

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

你读过解释它只与某些Web服务器设置相关的部分吗?这不是你可以选择或使用的东西。而setlocale是一个很好的潜在副作用的例子。(除了它在最新的Windows版本上每个线程都可以工作。)

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

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.

来源。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值