标签:com class code java tar ext art get ble int cti
happens-before relation on memory operations such as reads and writes of shared variables. The results of a write by one thread
are guaranteed to be visible to a read by another thread only if the write operation happens-before the read operation.
The synchronized and volatile constructs,
as well as
the Thread.start() and Thread.join()methods,
can form happens-before
relationships. In particular:
synchronized block or method exit) of a
monitor happens-before every subsequent lock
(synchronized block or methodentry) 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 similarmemory 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:
removal of that element from the collection in another thread.
Runnable to
an Executorhappen-before its execution begins.
Similarly for Callablessubmitted to an ExecutorService.
Futurehappen-before actions subsequent to
the retrieval of theresult via Future.get() in another thread.
Lock.unlock, Semaphore.release,
and CountDownLatch.countDown happen-beforeactions 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.
Exchanger, actions prior to
the exchange() in each thread happen-before those subsequent to the
corresponding exchange() in another thread.
CyclicBarrier.awaithappen-before actions
performed by the barrier action, and actions performed by the barrieraction happen-before actions subsequent to a successful
return from the corresponding await in other
threads.
Java Concurrent happens-before,码迷,mamicode.com
Java Concurrent happens-before
标签:com class code java tar ext art get ble int cti
原文地址:http://www.cnblogs.com/yuyutianxia/p/3698241.html