您还应该记得,在方法调用之间保留状态的静态类在默认情况下应该是线程安全的。
You should also remember that static classes that preserve state between method calls should be made thread safe by default.
因为它将从传递它的xsl中预编译转换指令,所以传递给其他方法甚至线程是安全的。
Because it precompiles the transformation instruction from the XSL it's handed, it is safe for handing off to other methods and even threads.
因为这些方法可能会从很多线程同时调用,它们也必须实现为线程安全的。
Because these methods might be called from any number of threads at the same time, they too must be implemented to be thread-safe.
TPL还拥有一套从前的线程或线程池所不具备的新功能,例如任务拥有一个安全的Cancel方法。
The TPL also has a new set of features not seen in either threads or thread pools. For example, Tasks have a safe Cancel method.
调用EJB和servlet方法时,容器会保留与线程相关联的上下文,如当前事务和安全principal。
When EJB and servlet methods are invoked, the container keeps context, such as the current transaction and security principal, associated with the thread.
注意所有方法,甚至需要同步get(),使类成为线程安全的类,从而确保没有任何更新信息丢失,所有线程都看到计数器的最新值。
Note that all the methods, even get(), need to be synchronized for the class to be thread-safe, to ensure that no updates are lost, and that all threads see the most recent value of the counter.
最安全的方法是让所有线程使用一个优先级值,不使用Thread .yield和将消耗整个CPU(因为它们不会被阻塞)的其他类型的自旋循环。
The safest approach is to make all threads use a single priority value and eliminate the use of Thread.yield and other kinds of spin loops that will fully consume a CPU because they never block.
Swing组件必须在EDT中进行访问,除非您调用文档化为线程安全的方法。
Swing components must be accessed in the EDT, unless you call methods documented as thread-safe.
因此ibinder方法必须实现为线程安全的。
IBinder methods must, therefore, be implemented to be thread-safe.
CipherService是多数开发者在保护数据时梦寐以求的东西:简单、无状态、线程安全的API,能够在一次方法调用中对整个数据进行加密或解密。
A CipherService is what most developers want when securing data: a simple, stateless, thread-safe API that can encrypt or decrypt data in its entirety in one method call.
清单9 中的整个方法完全是线程安全的,因为列表处理中使用的整个中间状态保存在参数的堆栈上。
有些类保留从一个方法调用到下一个方法调用的状态信息,要在实践中使这样的类成为线程安全的是困难的。
Some classes retain state information from one method invocation to the next, and it is difficult to make such classes thread-safe in any practical way.
该方法线程是否安全?
您可能偶尔会思考是否要同步化这个方法调用,还是只同步化该方法的线程安全子集。
You may have occasionally pondered whether to synchronize an entire method call or only the thread-safe subset of that method.
一旦您实现了在方法调用之间保持状态的重要类,该类的使用者就会希望了解有关线程安全和性能的详细信息。
As soon as you implement a nontrivial class maintaining state between method calls, consumers of the class will want to know details about thread safety and performance.
在某些场合,方法可能会从不止一个线程中被调用,因此这些方法必须是写成线程安全的。
In some situations, the methods you implement might be called from more than one thread, and therefore must be written to be thread-safe.
在我的并行vm上,会调用一个线程不安全的方法(使用c编写)。首先,VM请求GVL,然后处理这个方法,接着释放GVL。
On my parallel VM, a non-thread safe method (written in c) is invoked, at first, VM acquires GVL, and process such a method, and releases GVL.
清单5中的LockPoolMap展示了线程安全的get和put方法,但把同步分散在了锁池中,充分降低了争用可能性。
The LockPoolMap in Listing 5 exposes thread-safe get and put methods, but spreads the synchronization over a pool of locks, reducing contention substantially.
为了确保实现是线程安全的,实现该接口的类应该在方法上使用synchronized关键字,或者在方法内部使用同步锁。
To ensure that your implementation is thread-safe, a class that implements this interface should use either the synchronized keyword on the methods or synchronized blocks within the methods.
Authorized Callsbean(见清单13)提供了一些线程安全的方法,用于管理这个经过授权的调用的集合。
The AuthorizedCalls bean (shown in Listing 13) provides thread-safe methods for managing the set of authorized calls.
这个方法是线程安全的。
使用这个类的方法可以安全地递增、递减、交换和比较任何线程中的值。
The methods of this class let you safely increment, decrement, exchange, and compare values from any thread.
和实例的方法相比,静态类的方法或多或少拥有更高的线程安全性。
Static class methods may support a different level of thread safety than those associated with an instance of that class.
如果这个方法使用外部的东西,不是线程安全的然后让它并行线程安全的或不使用。
If this method USES something external that's not thread safe then either make it thread safe or don't use parallel.
最安全的方法就是引入一种机制(例如一个公共属性)来向目标线程发出信号,让目标线程请求中断。
The safest is to introduce a mechanism, such as a common property, that signals the target thread to request an interrupt.
它与多线程执行和这些线程都不怎么安全地从主方法叫什么?
How it relates to multiple threads of execution and how those threads are not safe to be called from the main method?
除枚举数之外,所有正则表达式类都是线程安全的或者可以通过同步方法转换成线程安全对象。
With the exception of enumerators, all regular expression classes are thread safe or can be converted into thread-safe objects by a synchronized method.
除枚举数之外,所有正则表达式类都是线程安全的或者可以通过同步方法转换成线程安全对象。
With the exception of enumerators, all regular expression classes are thread safe or can be converted into thread-safe objects by a synchronized method.
应用推荐