jaroslav@1890: /*
jaroslav@1890: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@1890: *
jaroslav@1890: * This code is free software; you can redistribute it and/or modify it
jaroslav@1890: * under the terms of the GNU General Public License version 2 only, as
jaroslav@1890: * published by the Free Software Foundation. Oracle designates this
jaroslav@1890: * particular file as subject to the "Classpath" exception as provided
jaroslav@1890: * by Oracle in the LICENSE file that accompanied this code.
jaroslav@1890: *
jaroslav@1890: * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@1890: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@1890: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jaroslav@1890: * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@1890: * accompanied this code).
jaroslav@1890: *
jaroslav@1890: * You should have received a copy of the GNU General Public License version
jaroslav@1890: * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@1890: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@1890: *
jaroslav@1890: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@1890: * or visit www.oracle.com if you need additional information or have any
jaroslav@1890: * questions.
jaroslav@1890: */
jaroslav@1890:
jaroslav@1890: /*
jaroslav@1890: * This file is available under and governed by the GNU General Public
jaroslav@1890: * License version 2 only, as published by the Free Software Foundation.
jaroslav@1890: * However, the following notice accompanied the original version of this
jaroslav@1890: * file:
jaroslav@1890: *
jaroslav@1890: * Written by Doug Lea with assistance from members of JCP JSR-166
jaroslav@1890: * Expert Group and released to the public domain, as explained at
jaroslav@1890: * http://creativecommons.org/publicdomain/zero/1.0/
jaroslav@1890: */
jaroslav@1890:
jaroslav@1890: package java.util.concurrent.locks;
jaroslav@1890:
jaroslav@1890: /**
jaroslav@1890: * A synchronizer that may be exclusively owned by a thread. This
jaroslav@1890: * class provides a basis for creating locks and related synchronizers
jaroslav@1890: * that may entail a notion of ownership. The
jaroslav@1890: * AbstractOwnableSynchronizer class itself does not manage or
jaroslav@1890: * use this information. However, subclasses and tools may use
jaroslav@1890: * appropriately maintained values to help control and monitor access
jaroslav@1890: * and provide diagnostics.
jaroslav@1890: *
jaroslav@1890: * @since 1.6
jaroslav@1890: * @author Doug Lea
jaroslav@1890: */
jaroslav@1890: public abstract class AbstractOwnableSynchronizer
jaroslav@1890: implements java.io.Serializable {
jaroslav@1890:
jaroslav@1890: /** Use serial ID even though all fields transient. */
jaroslav@1890: private static final long serialVersionUID = 3737899427754241961L;
jaroslav@1890:
jaroslav@1890: /**
jaroslav@1890: * Empty constructor for use by subclasses.
jaroslav@1890: */
jaroslav@1890: protected AbstractOwnableSynchronizer() { }
jaroslav@1890:
jaroslav@1890: /**
jaroslav@1890: * The current owner of exclusive mode synchronization.
jaroslav@1890: */
jaroslav@1890: private transient Thread exclusiveOwnerThread;
jaroslav@1890:
jaroslav@1890: /**
jaroslav@1890: * Sets the thread that currently owns exclusive access. A
jaroslav@1890: * null argument indicates that no thread owns access.
jaroslav@1890: * This method does not otherwise impose any synchronization or
jaroslav@1890: * volatile field accesses.
jaroslav@1890: */
jaroslav@1890: protected final void setExclusiveOwnerThread(Thread t) {
jaroslav@1890: exclusiveOwnerThread = t;
jaroslav@1890: }
jaroslav@1890:
jaroslav@1890: /**
jaroslav@1890: * Returns the thread last set by
jaroslav@1890: * setExclusiveOwnerThread, or null if never
jaroslav@1890: * set. This method does not otherwise impose any synchronization
jaroslav@1890: * or volatile field accesses.
jaroslav@1890: * @return the owner thread
jaroslav@1890: */
jaroslav@1890: protected final Thread getExclusiveOwnerThread() {
jaroslav@1890: return exclusiveOwnerThread;
jaroslav@1890: }
jaroslav@1890: }