要创建一个线程局部变量,请实例化类ThreadLocal的一个对象。
To create a thread-local variable, you instantiate an object of class ThreadLocal.
在生产环境中,可能要面对以 GB 字节计算的堆,数以百计的线程,数以千计的类加载器,数以万计的类以及巨大数目的对象。
In a production environment, there may well be many gigabytes of heap, hundreds of threads, thousands of classloaders, tens of thousands of classes, and a huge number of objects.
在stockquotegenerator类(一个单态类)的构造函数中,我们启动了一个新线程,并向该线程分配了一个Runnable对象。
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.
最大的区别就在与System.Timers.Timer类是对Win32可等待定时对象的一个包装,并在工作者线程上产生一个时间片消失事件而不是在UI线程上产生一个时间标记事件。
The biggest difference is that System.Timers.Timer is a wrapper around Win32 waitable timer objects and raises an Elapsed event on a worker thread rather than a Tick event on the UI thread.
Lock类只是普通的类,JVM不知道具体哪个线程拥有 Lock对象。
The Lock classes are just ordinary classes, and the JVM does not (yet) have any knowledge of which Lock objects are owned by specific threads.
除枚举数之外,所有正则表达式类都是线程安全的或者可以通过同步方法转换成线程安全对象。
With the exception of enumerators, all regular expression classes are thread safe or can be converted into thread-safe objects by a synchronized method.
数据库结构使用了MFC的类,这些类是线程安全设计的,能够让访问不同对象时不出问题。
The structures use MFC classes that are thread-safe already for threads accessing different objects.
在后面一种情况中,同一时间只会有一个线程可以执行这个类方法,因为对于所有的调用者来说,都只有一个类对象可被使用。
In the latter case, of course, only one thread at a time is allowed to execute a class method because there is only one class object that is Shared by all callers.
在后面一种情况中,同一时间只会有一个线程可以执行这个类方法,因为对于所有的调用者来说,都只有一个类对象可被使用。
In the latter case, of course, only one thread at a time is allowed to execute a class method because there is only one class object that is Shared by all callers.
应用推荐