To create a thread-local variable, you instantiate an object of class ThreadLocal.
要创建一个线程局部变量,请实例化类ThreadLocal的一个对象。
Making a class thread safe requires additional care during the implementation and testing of the class.
使一个类线程安全需要在实现和测试该类时非常小心。
It may be easier to manage the use of a non-thread-safe class than to try and make the class thread-safe.
管理非线程安全类的使用比试图使类成为线程安全的要更容易些。
Sometimes, it is very difficult to make a class thread-safe without compromising its functionality, ease of use, or performance.
有时,要在不影响类的功能、易用性或性能的情况下使类成为线程安全的是很困难的。
This instance is used for all messages that are sent into the partition, making members of this class thread safe and providing the opportunity to cache required resources.
这个实例被用于发送到该分区中的所有消息,使这个类的成员线程安全并提供缓存必要资源的机会。
It is often the easiest way to render a stateful class thread-safe, or to encapsulate non-thread-safe classes so that they can safely be used in multithreaded environments.
它常常是把有状态类描绘成线程安全的,或者封装非线程安全类以使它们能够在多线程环境中安全地使用的最容易的方式。
In this case, the delegation model is a proper graph (with cycles), and so a deadlock can occur as a result of particular class relationships and thread usage.
在本例中,委托模型是一个正确的图(带有循环),所以死锁的发生可能是使用特定的类关系和线程的结果。
The callback handler class has two thread local variables that can store the user ID and password from the client instance.
这个回调处理器类拥有两个线程本地变量,用于存储来自客户端实例的用户ID和密码。
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.
一旦您实现了在方法调用之间保持状态的重要类,该类的使用者就会希望了解有关线程安全和性能的详细信息。
The parent of this class loader will be the class loader of the current thread context.
类加载器的父类加载器将是当前线程上下文的类加载器。
Just like the rest of the code in a typical Windows Forms application, any code that resides inside a timer event handler (for this type of timer class) is executed using the application's UI thread.
就像一个典型窗体程序里的其它代码一样,任何驻留在一个定时器事件处理函数(指的是该类型的定时器类)中的代码也是使用应用程序的UI线程所执行。
If the pool class does not catch these, then the thread will simply exit and the size of the thread pool will be permanently reduced by one.
如果池类没有捕捉到它们,那么线程只会退出而线程池的大小将会永久减少一个。
Consider a thread-safe container class - a data structure that guarantees thread safety to its clients.
可以考虑使用一个线程安全容器类—一个保证用户操作线程安全的数据结构。
GC roots can be found in the root stacks, in thread execution stacks, and in object and class fields.
GC根能在根堆里找到,在线成执行堆,在对象和类域里。
This scenario only occurs when the class calling the interruptible method is part of a Thread, not a Runnable or general-purpose library code, as illustrated in Listing 5.
只有当调用可中断方法的类是Thread的一部分,而不是Runnable或通用库代码的情况下,才会发生这样的场景,清单 5演示了这种情况。
As an example, the code in Listing 1 USES an anonymous class to create a Thread Factory.
例如,清单1所示的代码使用一个匿名类创建了一个Thread Factory。
This was achieved by adding a general "catch-all" block in the Thread class.
这一目标是通过在thread类中添加一个通用的“catch - all”代码块来实现的。
In looking at the code, you can see that we added another instance of a queue, and then passed that queue into the first thread pool class, ThreadURL.
分析这段代码时您可以看到,我们添加了另一个队列实例,然后将该队列传递给第一个线程池类ThreadURL。
Each worker thread performs some bit of work using the TaskHandler class.
每个工作者线程使用taskhandler类执行一部分工作。
When the bot is used, this property is read and each custom class is run as a thread of the main Watchit bot.
当使用bot时,该属性会被读取且每个自定义类作为主watchit bot的一个线程运行。
You don't call the ThreadPoolExecutor constructor directly to create a thread pool but instead use the Executors utility class to create one.
使用Executors工具类来创建线程池,而不是直接调用ThreadPoolExecut or构造器来创建。
This constructor lets you specify the priority, memory sizes, and period for a thread, along with the class that represents the thread to be run (a class that extends PeriodicThread).
此构造函数让您能够指定优先级、内存大小、线程周期和表示要运行的线程的类(扩展periodicthread的类)。
In the constructor of StockQuoteGenerator class, which is a singleton class, we are starting a new thread and assigning a Runnable object to that thread.
在stockquotegenerator类(一个单态类)的构造函数中,我们启动了一个新线程,并向该线程分配了一个Runnable对象。
The PresentationReconciler class updates the text's appearance with every keystroke, and the Reconciler class runs in a daemon thread, parsing the document without holding up the user interface (UI).
presentationreconciler类根据每次击键更新文本的外观,而Reconciler类运行一个守护线程,不必将用户界面(UI)挂起就能解析该文档。
Class initialization Any type of regular or real-time thread can initialize a class, including a NHRT, which can cause unexpected MemoryAccessError.
类初始化任何类型的常规或实时线程都可以初始化类,包括NHRT(它可能导致意外的MemoryAccessError)。
The java.lang package provides a thread class that supports methods to start and stop threads and set thread priorities, among other things.
langpackage提供了线程类,支持开始,停止进程,设置进程优先级等等。
The PeriodicThreadDescriptor class describes a thread to be started as part of a group. It provides a single public constructor.
PeriodicThreadDescriptor类描述了一个线程作为线程组的一部分启动。
A dictionary or a class is likely to be a better data structure for thread management. As a quick example, below is a class that can (almost) drop in for the threads list in the examples.
字典或类可能是线程管理中更好的数据结构。
To create a new non real-time thread the existing thread class is used unchanged.
使用现有的Thread类、不做任何改动,就能创建一个非实时线程。
Any access to the data repository is made through a thread-safe wrapper class named RepositoryWrapper.
对数据存储库的所有访问都是通过一个名为RepositoryWrapper的线程安全类实现的。
应用推荐