synchronized关键字的内存语义及实现

2020-09-05
阅读 11 分钟
1.6k
Synchronization has several aspects. The most well-understood is mutual exclusion -- only one thread can hold a monitor at once, so synchronizing on a monitor means that once one thread enters a synchronized block protected by a monitor, no other thread can enter a block protected by that monitor...

Synchronization 中英文对照翻译

2020-09-02
阅读 8 分钟
1.7k
One of the major strengths of the Java programming language is its built-in support for multi-threaded programs. An object that is shared between multiple threads can be locked in order to synchronize its access. Java provides primitives to designate critical code regions, which act on a shared o...

JSR-133 FAQ 中英对照版翻译

2020-09-02
阅读 28 分钟
1.4k
In multiprocessor systems, processors generally have one or more layers of memory cache, which improves performance both by speeding access to data (because the data is closer to the processor) and reducing traffic on the shared memory bus (because many memory operations can be satisfied by local...

The JSR-133 Cookbook for Compiler Writers 中英对照版翻译

2020-08-21
阅读 40 分钟
1.5k
Preface: Over the 10+ years since this was initially written, many processor and language memory model specifications and issues have become clearer and better understood. And many have not. While this guide is maintained to remain accurate, it is incomplete about some of these evolving details. ...

Java 原子类的使用及原理分析

2020-08-16
阅读 20 分钟
2.3k
前面两篇文章,一篇文章我们介绍了Unsafe中的CAS,另一篇文章介绍了volatile语义及其实现,再来学习今天的Java原子类可以说是水到渠成。再简单回顾一下Unsafe中CAS——该操作通过将内存中的值与指定数据进行比较,当数值一样时将内存中的数据替换为新的值;至于volatile则提供了可见性(每次读写都可以拿到最新值)和重排序...

volatile域的语义及其实现

2020-08-08
阅读 8 分钟
2.1k
根据维基百科的定义:在一个共享内存多处理器系统中,每个处理器都有一个单独的缓存,可以有很多共享数据副本:一个在主内存中,一个在每个请求它的处理器的本地缓存中。 当一个数据副本被更改时,其他副本必须反映该更改。 缓存一致性是确保共享操作数(数据)值的更改及时在整个系统中传播的学科。下面图1是缓存不一致...

Unsafe介绍及CAS原理解析

2020-07-26
阅读 7 分钟
4.3k
JavaDoc说, Unsafe提供了一组用于执行底层的,不安全操作的方法。那么具体有哪些方法呢,我画了一张图。可以看到Unsafe中提供了CAS,内存操作,线程调度,本机信息,Class相关方法,查看和设置某个对象或字段,内存分配和释放相关操作,内存地址获取相关方法。我自己抽空对上述方法进行了注释,你可以在这里看到。那么如...