摘要
解决Java多线程同步的方法是在需要同步的方法签名中加入synchronized关键字,使用synchronized对需要进行同步的代码段进行同步,或使用JDK 5中提供的java.util.concurrent.lock包中的Lock对象。为解决多个线程对同一变量进行访问时可能发生的安全性问题,不仅可以采用同步机制,更可以通过JDK中加入的ThreadLocal来保证更好的并发性。
The solution method of Java multi-thread synchronization is to add synchronization synchronized keyword.The synchronize code is synchronized by using synchronized,or the java.util.concurrent.lock package provided in JDK 5.In addition,the security issues,which perhaps occur during the multiple threads access the same variables,is solved by not only synchronization mechanism,but also adding ThreadLocal in JDK.
出处
《河北工程大学学报(自然科学版)》
CAS
2011年第2期105-108,共4页
Journal of Hebei University of Engineering:Natural Science Edition
关键词
线程
同步
有序性
可见性
互斥
thread
synchronism
orderliness
visibility
exclusiveness