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

Comparing jsr166/src/main/java/util/concurrent/Lock.java (file contents):
Revision 1.1 by tim, Wed May 14 21:30:47 2003 UTC vs.
Revision 1.2 by dl, Tue May 27 18:14:40 2003 UTC

# Line 1 | Line 1
1 + /*
2 + * Written by Doug Lea with assistance from members of JCP JSR-166
3 + * Expert Group and released to the public domain. Use, modify, and
4 + * redistribute this code in any way without acknowledgement.
5 + */
6 +
7   package java.util.concurrent;
8  
9   /**
# Line 40 | Line 46 | package java.util.concurrent;
46   *     l.lock();
47   *     try {
48   *         // access the resource protected by this lock
43 *     } catch ( ... ) {
44 *         // ensure consistency before releasing lock
49   *     } finally {
50   *         l.unlock();
51   *     }
52   * </tt></pre>
49 * This mimics the automatic release property of built-in monitor locks, and
50 * carries with it the same responsibility for ensuring that if an exception
51 * occurs then the resource is left in a consistent state before the lock
52 * is released.
53   *
54   * <p><tt>Lock</tt> implementations provide additional functionality over the
55   * use
# Line 120 | Line 120 | package java.util.concurrent;
120   * @revised $Date$
121   * @editor $Author$
122   *
123 < */
123 > **/
124   public interface Lock {
125  
126      /**
# Line 136 | Line 136 | public interface Lock {
136       * The circumstances and the exception type must be documented by that
137       * <tt>Lock</tt> implementation.
138       *
139 <     */
140 <    void lock();
139 >     **/
140 >    public void lock();
141  
142      /**
143       * Acquires the lock unless the current thread is  
144       * {@link Thread#interrupt interrupted}.
145       * <p>Acquires the lock if it is available and returns immediately.
146       * <p>If the lock is not available then
147 <     * the current thread becomes disabled for thread scheduling
147 >     * the current thread thread becomes disabled for thread scheduling
148       * purposes and lies dormant until one of two things happens:
149       * <ul>
150       * <li> The lock is acquired by the current thread; or
# Line 178 | Line 178 | public interface Lock {
178       *
179       * @see Thread#interrupt
180       *
181 <     */
182 <    void lockInterruptibly() throws InterruptedException;
181 >     **/
182 >    public void lockInterruptibly() throws InterruptedException;
183  
184  
185      /**
# Line 206 | Line 206 | public interface Lock {
206       *
207       * @return <tt>true</tt> if the lock was acquired and <tt>false</tt>
208       * otherwise.
209 <     */
210 <    boolean tryLock();
209 >     **/
210 >    public boolean tryLock();
211  
212      /**
213       * Acquires the lock if it is free within the given waiting time and the
# Line 250 | Line 250 | public interface Lock {
250       * The circumstances and the exception type must be documented by that
251       * <tt>Lock</tt> implementation.
252       *
253 <     * @param timeout the maximum time to wait for the lock
254 <     * @param granularity the time unit of the <tt>timeout</tt> argument.
253 >     * @param time the maximum time to wait for the lock
254 >     * @param unit the time unit of the <tt>time</tt> argument.
255       * @return <tt>true</tt> if the lock was acquired and <tt>false</tt>
256       * if the waiting time elapsed before the lock was acquired.
257       *
# Line 261 | Line 261 | public interface Lock {
261       *
262       * @see Thread#interrupt
263       *
264 <     */
265 <    boolean tryLock(long timeout, TimeUnit granularity)
266 <        throws InterruptedException;
264 >     **/
265 >    public boolean tryLock(long time, TimeUnit unit) throws InterruptedException;
266  
267      /**
268       * Releases the lock.
# Line 274 | Line 273 | public interface Lock {
273       * an (unchecked) exception if the restriction is violated.
274       * Any restrictions and the exception
275       * type must be documented by that <tt>Lock</tt> implementation.
276 <     */
277 <    void unlock();
276 >     **/
277 >    public void unlock();
278  
279      /**
280       * Returns a {@link Condition} instance that is bound to this <tt>Lock</tt>
# Line 298 | Line 297 | public interface Lock {
297       * @return A {@link Condition} instance for this <tt>Lock</tt> instance.
298       * @throws UnsupportedOperationException if this <tt>Lock</tt>
299       * implementation does not support conditions.
300 <     */
301 <    Condition newCondition();
300 >     **/
301 >    public Condition newCondition();
302  
303   }
304  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines