KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > util > concurrent > locks > AbstractOwnableSynchronizer


1 /*
2  * @(#)AbstractOwnableSynchronizer.java 1.2 05/11/17
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.util.concurrent.locks;
9
10 /**
11  * A synchronizer that may be exclusively owned by a thread. This
12  * class provides a basis for creating locks and related synchronizers
13  * that may entail a notion of ownership. The
14  * <tt>AbstractOwnableSynchronizer</tt> class itself does not manage or
15  * use this information. However, subclasses and tools may use
16  * appropriately maintained values to help control and monitor access
17  * and provide diagnostics.
18  *
19  * @since 1.6
20  * @author Doug Lea
21  */

22 public abstract class AbstractOwnableSynchronizer
23     implements java.io.Serializable JavaDoc {
24
25     /** Use serial ID even though all fields transient. */
26     private static final long serialVersionUID = 3737899427754241961L;
27
28     /**
29      * Empty constructor for use by subclasses.
30      */

31     protected AbstractOwnableSynchronizer() { }
32
33     /**
34      * The current owner of exclusive mode synchronization.
35      */

36     private transient Thread JavaDoc exclusiveOwnerThread;
37
38     /**
39      * Sets the thread that currently owns exclusive access. A
40      * <tt>null</tt> argument indicates that no thread owns access.
41      * This method does not otherwise impose any synchronization or
42      * <tt>volatile</tt> field accesses.
43      */

44     protected final void setExclusiveOwnerThread(Thread JavaDoc t) {
45         exclusiveOwnerThread = t;
46     }
47
48     /**
49      * Returns the thread last set by
50      * <tt>setExclusiveOwnerThread</tt>, or <tt>null</tt> if never
51      * set. This method does not otherwise impose any synchronization
52      * or <tt>volatile</tt> field accesses.
53      * @return the owner thread
54      */

55     protected final Thread JavaDoc getExclusiveOwnerThread() {
56         return exclusiveOwnerThread;
57     }
58 }
59
Popular Tags