【翻译六】什么是未正确同步?

What do you mean by “incorrectly synchronized”?

Incorrectly synchronized code can mean different things to different people. When we talk about incorrectly synchronized code in the context of the Java Memory Model, we mean any code where线程

不一样的人会写出不一样的bug,也会出现各类不一样的同步问题,但对于JMM,如下状况就是未正确同步的code

  1. there is a write of a variable by one thread,排序

  2. there is a read of the same variable by another thread and同步

  3. the write and read are not ordered by synchronizationit

  4. 一条线程正在写入一个变量io

  5. 另外一条线程正在读取这个变量thread

  6. 这两个线程的读写没有经过同步进行强制排序变量

When these rules are violated, we say we have a data race on that variable. A program with a data race is an incorrectly synchronized program.bug

这种状况下,咱们就称之为这个变量存在数据竞争。有数据竞争的程序,就是一个未正确同步的程序。程序

相关文章
相关标签/搜索