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
there is a write of a variable by one thread,排序
there is a read of the same variable by another thread and同步
the write and read are not ordered by synchronizationit
一条线程正在写入一个变量io
另外一条线程正在读取这个变量thread
这两个线程的读写没有经过同步进行强制排序变量
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
这种状况下,咱们就称之为这个变量存在数据竞争。有数据竞争的程序,就是一个未正确同步的程序。程序