因为根据设计它是线程安全的,创建它之后可以把它缓存在一个公共静态最终变量中,或者包装在单实例模式中以供以后访问。
Since it is thread safe by design, you might cache it in a public static final variable, or wrap it in a singleton pattern after creation for later access.
我们没有定义任何会引起线程安全问题的变量。
We don't declare any variables that might cause thread-safety issues.
请注意,readdir不是线程安全的,因为所返回的结构是存储在函数库中的一个静态变量。
Note that readdir is not thread-safe, because the returned structure is a static variable stored in the function library.
第一个条件的限制使volatile变量不能用作线程安全计数器。
The first condition disqualifies volatile variables from being used as thread-safe counters.
在一个线程安全的程序中,只有一个写线程能够修改这个变量;而其他的线程则可以读取volatile声明变量的最新值。
In a thread-safe program, only one writing thread can modify the variable; other threads can read the up-to-date value by declaring the variable volatile.
静态局部变量的指针不是线程安全的?
不要使用不稳定变量。锁定对象或域,而不是去保证决定性和线程安全访问。
Do not use volatile variables. Lock your object or fields instead to guarantee deterministic and thread-safe Access.
所有全局变量都是线程安全的。如果允许一个以上线程访问全局变量,应该采用互斥之类的机制。
If some objects can be accessed by more than one thread, make sure member variables are protected by synchronization mechanisms.
所有全局变量都是线程安全的。如果允许一个以上线程访问全局变量,应该采用互斥之类的机制。
If some objects can be accessed by more than one thread, make sure member variables are protected by synchronization mechanisms.
应用推荐