< prev index next >

src/java.corba/share/classes/com/sun/corba/se/impl/orbutil/concurrent/Sync.java

Print this page




 259  *       if (lock.attempt(0))
 260  *         return true;
 261  *     }
 262  *     // Second phase - use timed waits
 263  *     long waitTime = 1; // 1 millisecond
 264  *     for (;;) {
 265  *       if (lock.attempt(waitTime))
 266  *         return true;
 267  *       else
 268  *         waitTime = waitTime * 3 / 2 + 1; // increase 50%
 269  *     }
 270  *   }
 271  * }
 272  * </pre>
 273  * <p>
 274  * In addition pure synchronization control, Syncs
 275  * may be useful in any context requiring before/after methods.
 276  * For example, you can use an ObservableSync
 277  * (perhaps as part of a LayeredSync) in order to obtain callbacks
 278  * before and after each method invocation for a given class.
 279  * <p>
 280 
 281  * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
 282 **/
 283 
 284 
 285 public interface Sync {
 286 
 287   /**
 288    *  Wait (possibly forever) until successful passage.
 289    *  Fail only upon interuption. Interruptions always result in
 290    *  `clean' failures. On failure,  you can be sure that it has not
 291    *  been acquired, and that no
 292    *  corresponding release should be performed. Conversely,
 293    *  a normal return guarantees that the acquire was successful.
 294   **/
 295 
 296   public void acquire() throws InterruptedException;
 297 
 298   /**
 299    * Wait at most msecs to pass; report whether passed.
 300    * <p>
 301    * The method has best-effort semantics:
 302    * The msecs bound cannot




 259  *       if (lock.attempt(0))
 260  *         return true;
 261  *     }
 262  *     // Second phase - use timed waits
 263  *     long waitTime = 1; // 1 millisecond
 264  *     for (;;) {
 265  *       if (lock.attempt(waitTime))
 266  *         return true;
 267  *       else
 268  *         waitTime = waitTime * 3 / 2 + 1; // increase 50%
 269  *     }
 270  *   }
 271  * }
 272  * </pre>
 273  * <p>
 274  * In addition pure synchronization control, Syncs
 275  * may be useful in any context requiring before/after methods.
 276  * For example, you can use an ObservableSync
 277  * (perhaps as part of a LayeredSync) in order to obtain callbacks
 278  * before and after each method invocation for a given class.
 279  *

 280  * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
 281  **/
 282 
 283 
 284 public interface Sync {
 285 
 286   /**
 287    *  Wait (possibly forever) until successful passage.
 288    *  Fail only upon interuption. Interruptions always result in
 289    *  `clean' failures. On failure,  you can be sure that it has not
 290    *  been acquired, and that no
 291    *  corresponding release should be performed. Conversely,
 292    *  a normal return guarantees that the acquire was successful.
 293   **/
 294 
 295   public void acquire() throws InterruptedException;
 296 
 297   /**
 298    * Wait at most msecs to pass; report whether passed.
 299    * <p>
 300    * The method has best-effort semantics:
 301    * The msecs bound cannot


< prev index next >