If you have two operations that require synchronization separated by a small block of thread-safe code, you are generally better just using a single synchronized block.
要是您想用一小块线程安全代码把要求同步的两个操作隔开,那么只使用一个同步块一般会更好些。
Note that this code is fully thread safe.
注意这样的代码是完全线程安全的。
On the surface it looks as though lock elision allows us to write thread safe code without any synchronization penalty for using in cases where it really wasn't needed.
从表面上看,锁省略似乎可以允许我们不必忍受同步带来的负担,就可以编写线程安全的代码了,前提是在同步的确是多余的情况下。
There is no straightforward way to make the code in Listing 1 thread-safe, making this idiom an accident waiting to happen.
没有直观的途径来使清单1中的代码是线程安全的,这使这种语言风格成为了一种等待时机发生的事故。
Once the class has been resolved, the original code location is modified in a thread-safe way to access the static field's address directly because that address is then known.
类一旦被解析,就会以一种线程安全的方式修改原始代码位置以便直接访问静态字段的地址,因为此时已获知该地址。
Batch application developers write code that is thread-safe and executes on a single thread.
批处理应用程序开发人员可以编写线程安全的、且在单个线程中执行的代码。
Now the UI is safe and the code is simpler, because it separates the work into the part that should be done on a worker thread and the part that should be done on the UI thread.
现在UI是安全的,代码也得到简化,因为任务分解成了工作线程内完成的部分和UI线程内完成的部分。
There is no straightforward way to make the code in Listing 1 thread-safe, making this idiom an accident waiting to happen.
没有什么简单的办法可用来把清单1中的代码变成线程安全的,这使得这一惯用技法变成了一个在等待时机发生的事故。
What this means is that the following code is not thread safe!
这表示下面的代码不是线程安全的。
If a caller wants to increment the foo property, the following code to do so is not thread-safe.
如果一个调用者想要增加foo属性值,以下完成该功能的代码就不是线程安全的。
This is simple (but difficult. makes buggy code easy) work to make them thread-safe (but many efforts are needed).
将其转换为线程安全是一件简单(其实很困难,编写充满bug的代码倒是很简单)的工作(但是需要更多的努力)。
This is a typical symptom of code that is not thread safe.
这是一个典型的症状是不是线程安全的代码。
将代码是线程安全的?
In other words, if you're using code that is not thread safe, you should either fix that code, or consider moving to the multi-process model.
换句话说,如果你使用的代码不是线程安全的,你需要修复你的代码,或者考虑使用多进程模型。
To help keep your provider thread-safe, you must verify that your code is blocked properly.
为使提供程序是线程安全的,必须确保代码被正确模块化。
To help keep your provider thread-safe, you must verify that your code is blocked properly.
为使提供程序是线程安全的,必须确保代码被正确模块化。
应用推荐