hb的含義,是以前的操做寫入的東西,對以後的操做都是可見的java
具備傳遞性,若是A hb B,B hb C,那麼A hb C併發
synchronized
block or method exit) of a monitor happens-before every subsequent lock (synchronized
block or method entry) of that same monitor. And because the happens-before relation is transitive, all actions of a thread prior to unlocking happen-before all actions subsequent to any thread locking that monitor.volatile
field happens-before every subsequent read of that same field. Writes and reads of volatile
fields have similar memory consistency effects as entering and exiting monitors, but do not entail mutual exclusion locking.start
on a thread happens-before any action in the started thread.join
on that thread.The methods of all classes in java.util.concurrent
and its subpackages extend these guarantees to higher-level synchronization. In particular:app
Runnable
to an Executor
happen-before its execution begins. Similarly for Callables
submitted to an ExecutorService
.Future
happen-before actions subsequent to the retrieval of the result via Future.get()
in another thread.Lock.unlock
, Semaphore.release
, and CountDownLatch.countDown
happen-before actions subsequent to a successful "acquiring" method such as Lock.lock
, Semaphore.acquire
, Condition.await
, and CountDownLatch.await
on the same synchronizer object in another thread.Lock.unlock
, Semaphore.release
, and CountDownLatch.countDown)老是hb 以後成功獲取鎖後發生的。
Exchanger
, actions prior to the exchange()
in each thread happen-before those subsequent to the corresponding exchange()
in another thread.CyclicBarrier.await
and Phaser.awaitAdvance
(as well as its variants) happen-before actions performed by the barrier action, and actions performed by the barrier action happen-before actions subsequent to a successful return from the corresponding await
in other threads.CyclicBarrier.await
and Phaser.awaitAdvance以前發生的,老是hb 被內存柵欄執行的動做,內存柵欄執行的動做,老是hb 其餘線程調用await返回以後