ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/package.html
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/package.html (file contents):
Revision 1.20 by jsr166, Sun Jun 12 00:33:30 2005 UTC vs.
Revision 1.21 by dl, Sun Aug 7 21:30:42 2005 UTC

# Line 139 | Line 139 | weakly consistent iterator is thread-saf
139   freeze the collection while iterating, so it may (or may not) reflect
140   any updates since the iterator was created.
141  
142 + <h2> Memory Consistency Properties </h2>
143 +
144 + <a href="http://java.sun.com/docs/books/jls/third_edition/html/memory.html">
145 + Chapter 17 of the Java Language Specification</a> defines the
146 + <i>happens-before</i> relation on memory operations such as reads and
147 + writes of shared variables.  The results of a write by one thread are
148 + guaranteed to be visible to a read by another thread only if the write
149 + operation <i>happens-before</i> the read operation.  The
150 + <tt>synchronized</tt> and <tt>volatile</tt> constructs, as well as the
151 + <tt>Thread.start()</tt> and <tt>Thread.join()</tt> methods, can form
152 + <i>happens-before</i> relationships. In particular:
153 +
154 + <ul>
155 +  <li>Each action in a thread happens before every action in that
156 +  thread that comes later in the program's order.
157 +
158 +  <li>An unlock (<tt>synchronized</tt> block or method exit) on a
159 +  monitor happens before every subsequent lock (<tt>synchronized</tt>
160 +  block or method entry) that same monitor.
161 +
162 +  <li>A write to a <tt>volatile</tt> field happens before every
163 +  subsequent read of that same field.
164 +
165 +  <li>A call to <tt>start</tt> on a thread happens before any actions in the
166 +  started thread.
167 +
168 +  <li>All actions in a thread happen before any other thread
169 +  successfully returns from a <tt>join</tt> on that thread.
170 +
171 + </ul>
172 +
173 + The methods of all classes in <tt>java.util.concurrent</tt> and its
174 + subpackages extend these guarantees to higher-level
175 + synchronization. In particular:
176 +
177 + <ul>
178 +
179 +  <li>State changes to any object made prior to placement into any
180 +  concurrent collection happen before this element is accessed via or
181 +  removed from that collection.
182 +
183 +  <li>State changes to a <tt>Runnable</tt> object made prior to
184 +  submission to an <tt>Executor</tt> happen before its execution. And
185 +  similarly for a <tt>Callable</tt> object submitted to an
186 +  <tt>ExecutorService</tt>.
187 +
188 +  <li>State changes to a <tt>Future</tt> made prior to it becoming
189 +  available happen before access via <tt>Future.get()</tt>.
190 +
191 +  <li>Actions prior to "releasing" synchronizer methods such as
192 +  <tt>Lock.unlock</tt>, <tt>Semaphore.release</tt>,
193 +  <tt>CountDownLatch.countDown<tt> and <tt>Condition.signal</tt>
194 +  happen before actions subsequent to "acquiring" methods such as
195 +  <tt>Lock.lock</tt>, <tt>Semaphore.acquire</tt>, and
196 +  <tt>CountDownLatch.await</tt> on the same synchronizer object.
197 +
198 +  <li>Actions prior to symmetric synchronizer methods such as
199 +  <tt>CyclicBarrier.await</tt> and <tt>Exchanger.exchange</tt> happen
200 +  before those subsequent to the matching actions in other threads.
201 +
202 + </ul>
203 +
204   @since 1.5
205  
206   </body> </html>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines