Happen-before八大规则

程序次序规则

同一个线程,书写在前面的代码happen-before后面的代码

Volatile规则

对一个volatile变量的写操作happen-before对该变量的读操作

锁规则

对一个锁的解锁操作happen-before对该锁的加锁操作

传递性

如果A happen-before B,B happen-before C,那么A happen-before C

线程启动规则

thread.start happen-before该线程任意操作

线程终止规则

线程任意操作happen-before thread.join

中断规则

thread.interrupt happen-before被中断线程检测到中断事件

对象终结规则

对象构建完成happen-before finalize方法的开始