摘要
Java存储模型是Java语言和Java虚拟机研究中的核心关键部分。Java语言规范规定:所有对基本类型的操作,除了对double/long类型的操作之外,都必须是原子级的。Java提供的volatile关键字可以使double/long变量实现变量级同步,但仍不能保证线程间同步。针对这些不足,结合实例分析了Java内存模型,synchronized方法,引入了硬件原语(CAS),给出了非阻塞算法的同步策略。
Java memory model (JMM) is an important topic in Java language and Java virtual machine (JVM) design. The Java Language Specification provides that all the primitive types of operations must be atomic except double/long types of operations. The keywords - volatile can achieve variable- sync for double/long variables, but still can not guarantee synchronization between threads. Based these deficiencies, this paper analyses Java Memory Model ( JMM ), synchronized methods and CAS. The strategy to design nonblocking algorithms for synchronizing non - atomic treatment of double and long is proposed.
出处
《微处理机》
2010年第1期79-82,85,共5页
Microprocessors