blob: 670e2c28f48e8f1ba2262735fc10086902457d6b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.5.0_06) on Sat Oct 14 18:42:11 PDT 2006 -->
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>
ReentrantLock (OpenJPA 0.9.0-incubating API)
</TITLE>
<META NAME="keywords" CONTENT="org.apache.openjpa.lib.util.concurrent.ReentrantLock class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="ReentrantLock (OpenJPA 0.9.0-incubating API)";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ReentrantLock.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Queue.html" title="interface in org.apache.openjpa.lib.util.concurrent"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/TimeUnit.html" title="class in org.apache.openjpa.lib.util.concurrent"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?org/apache/openjpa/lib/util/concurrent/ReentrantLock.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="ReentrantLock.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.openjpa.lib.util.concurrent</FONT>
<BR>
Class ReentrantLock</H2>
<PRE>
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>
<IMG SRC="../../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.openjpa.lib.util.concurrent.ReentrantLock</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A>, <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public class <B>ReentrantLock</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A><DT>implements <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A></DL>
</PRE>
<P>
A reentrant mutual exclusion <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Lock</CODE></A> with the same basic
behavior and semantics as the implicit monitor lock accessed using
<tt>synchronized</tt> methods and statements, but with extended capabilities.
A <tt>ReentrantLock</tt> is <em>owned</em> by the thread last
successfully locking, but not yet unlocking it. A thread invoking
<tt>lock</tt> will return, successfully acquiring the lock, when
the lock is not owned by another thread. The method will return
immediately if the current thread already owns the lock. This can
be checked using methods <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#isHeldByCurrentThread()"><CODE>isHeldByCurrentThread()</CODE></A>, and <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#getHoldCount()"><CODE>getHoldCount()</CODE></A>. The constructor for this class accepts an optional
<em>fairness</em> parameter. When set <tt>true</tt>, under
contention, locks favor granting access to the longest-waiting
thread. Otherwise this lock does not guarantee any particular
access order. Programs using fair locks accessed by many threads
may display lower overall throughput(i.e., are slower; often much
slower) than those using the default setting, but have smaller
variances in times to obtain locks and guarantee lack of
starvation. Note however, that fairness of locks does not guarantee
fairness of thread scheduling. Thus, one of many threads using a
fair lock may obtain it multiple times in succession while other
active threads are not progressing and not currently holding the lock.
Also note that the untimed <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#tryLock()"><CODE>tryLock</CODE></A> method does not
honor the fairness setting. It will succeed if the lock
is available even if other threads are waiting.
It is recommended practice to <em>always</em> immediately
follow a call to <tt>lock</tt> with a <tt>try</tt> block, most
typically in a before/after construction such as:
<pre> class X { private final ReentrantLock lock = new ReentrantLock();
// ... public void m() { lock.lock(); // block until condition holds try {
// ... method body } finally { lock.unlock() } } }
</pre> In addition to implementing the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Lock</CODE></A> interface, this
class defines methods <tt>isLocked</tt> and
<tt>getLockQueueLength</tt>, as well as some associated
<tt>protected</tt> access methods that may be useful for
instrumentation and monitoring.
Serialization of this class behaves in the same way as built-in
locks: a deserialized lock is in the unlocked state, regardless of
its state when serialized.
This lock supports a maximum of 2147483647 recursive locks by
the same thread. Attempts to exceed this limit result in
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Error.html" title="class or interface in java.lang"><CODE>Error</CODE></A> throws from locking methods.
<P>
<P>
<DL>
<DT><B>Since:</B></DT>
<DD>1.5</DD>
<DT><B>Author:</B></DT>
<DD>Doug Lea, Dawid Kurzyniec</DD>
<DT><B>See Also:</B><DD><A HREF="../../../../../../serialized-form.html#org.apache.openjpa.lib.util.concurrent.ReentrantLock">Serialized Form</A></DL>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#ReentrantLock()">ReentrantLock</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates an instance of <tt>ReentrantLock</tt>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#ReentrantLock(boolean)">ReentrantLock</A></B>(boolean&nbsp;fair)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates an instance of <tt>ReentrantLock</tt> with the
given fairness policy.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#getHoldCount()">getHoldCount</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queries the number of holds on this lock by the current thread.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" title="class or interface in java.lang">Thread</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#getOwner()">getOwner</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<tt>null</tt> if not owned.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#getQueuedThreads()">getQueuedThreads</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a collection containing threads that may be waiting to
acquire this lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#getQueueLength()">getQueueLength</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an estimate of the number of threads waiting to
acquire this lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#getWaitingThreads(org.apache.openjpa.lib.util.concurrent.Condition)">getWaitingThreads</A></B>(<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A>&nbsp;condition)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a collection containing those threads that may be
waiting on the given condition associated with this lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#getWaitQueueLength(org.apache.openjpa.lib.util.concurrent.Condition)">getWaitQueueLength</A></B>(<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A>&nbsp;condition)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns an estimate of the number of threads waiting on the
given condition associated with this lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#hasQueuedThread(java.lang.Thread)">hasQueuedThread</A></B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" title="class or interface in java.lang">Thread</A>&nbsp;thread)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queries whether the given thread is waiting to acquire this
lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#hasQueuedThreads()">hasQueuedThreads</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queries whether any threads are waiting to acquire this lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#hasWaiters(org.apache.openjpa.lib.util.concurrent.Condition)">hasWaiters</A></B>(<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A>&nbsp;condition)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queries whether any threads are waiting on the given condition
associated with this lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#isFair()">isFair</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns true if this lock has fairness set true.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#isHeldByCurrentThread()">isHeldByCurrentThread</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queries if this lock is held by the current thread.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#isLocked()">isLocked</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Queries if this lock is held by any thread.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#lock()">lock</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Acquires the lock.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#lockInterruptibly()">lockInterruptibly</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Acquires the lock unless the current thread is
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupted</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#newCondition()">newCondition</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Condition</CODE></A> instance for use with this
<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Lock</CODE></A> instance.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#toString()">toString</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a string identifying this lock, as well as its lock
state.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#tryLock()">tryLock</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Acquires the lock only if it is not held by another thread at the time
of invocation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#tryLock(long, org.apache.openjpa.lib.util.concurrent.TimeUnit)">tryLock</A></B>(long&nbsp;timeout,
<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/TimeUnit.html" title="class in org.apache.openjpa.lib.util.concurrent">TimeUnit</A>&nbsp;unit)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Acquires the lock if it is not held by another thread within the given
waiting time and the current thread has not been
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupted</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#unlock()">unlock</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Attempts to release this lock.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="ReentrantLock()"><!-- --></A><H3>
ReentrantLock</H3>
<PRE>
public <B>ReentrantLock</B>()</PRE>
<DL>
<DD>Creates an instance of <tt>ReentrantLock</tt>.
This is equivalent to using <tt>ReentrantLock(false)</tt>.
<P>
</DL>
<HR>
<A NAME="ReentrantLock(boolean)"><!-- --></A><H3>
ReentrantLock</H3>
<PRE>
public <B>ReentrantLock</B>(boolean&nbsp;fair)</PRE>
<DL>
<DD>Creates an instance of <tt>ReentrantLock</tt> with the
given fairness policy.
<P>
<DL>
<DT><B>Parameters:</B><DD><CODE>fair</CODE> - true if this lock will be fair; else false</DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="lock()"><!-- --></A><H3>
lock</H3>
<PRE>
public void <B>lock</B>()</PRE>
<DL>
<DD>Acquires the lock.
Acquires the lock if it is not held by another thread and returns
immediately, setting the lock hold count to one. If the current thread
already holds the lock then the hold count is incremented by one and
the method returns immediately.
If the lock is held by another thread then the
current thread becomes disabled for thread scheduling
purposes and lies dormant until the lock has been acquired,
at which time the lock hold count is set to one.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html#lock()">lock</A></CODE> in interface <CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A></CODE></DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="lockInterruptibly()"><!-- --></A><H3>
lockInterruptibly</H3>
<PRE>
public void <B>lockInterruptibly</B>()
throws <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InterruptedException.html" title="class or interface in java.lang">InterruptedException</A></PRE>
<DL>
<DD>Acquires the lock unless the current thread is
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupted</CODE></A>.
Acquires the lock if it is not held by another thread and returns
immediately, setting the lock hold count to one.
If the current thread already holds this lock then the hold count
is incremented by one and the method returns immediately.
If the lock is held by another thread then the
current thread becomes disabled for thread scheduling
purposes and lies dormant until one of two things happens:
<ul>
<li>The lock is acquired by the current thread; or
<li>Some other thread <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupts</CODE></A> the current
thread.
</ul> If the lock is acquired by the current thread then the lock hold
count is set to one. If the current thread:
<ul>
<li>has its interrupted status set on entry to this method; or
<li>is <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupted</CODE></A> while acquiring the lock,
</ul>
then <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InterruptedException.html" title="class or interface in java.lang"><CODE>InterruptedException</CODE></A> is thrown and the current thread's
interrupted status is cleared.
In this implementation, as this method is an explicit interruption
point, preference is
given to responding to the interrupt over normal or reentrant
acquisition of the lock.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html#lockInterruptibly()">lockInterruptibly</A></CODE> in interface <CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InterruptedException.html" title="class or interface in java.lang">InterruptedException</A></CODE> - if the current thread is interrupted<DT><B>See Also:</B><DD><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>Thread.interrupt()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="tryLock()"><!-- --></A><H3>
tryLock</H3>
<PRE>
public boolean <B>tryLock</B>()</PRE>
<DL>
<DD>Acquires the lock only if it is not held by another thread at the time
of invocation. Acquires the lock if it is not held by another thread and
returns immediately with the value <tt>true</tt>, setting the
lock hold count to one. Even when this lock has been set to use a
fair ordering policy, a call to <tt>tryLock()</tt> <em>will</em>
immediately acquire the lock if it is available, whether or not
other threads are currently waiting for the lock.
This &quot;barging&quot; behavior can be useful in certain
circumstances, even though it breaks fairness. If you want to honor
the fairness setting for this lock, then use
<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#tryLock(long, org.apache.openjpa.lib.util.concurrent.TimeUnit)"><CODE>tryLock(0, TimeUnit.SECONDS) </CODE></A>
which is almost equivalent(it also detects interruption).
If the current thread
already holds this lock then the hold count is incremented by one and
the method returns <tt>true</tt>.
If the lock is held by another thread then this method will return
immediately with the value <tt>false</tt>.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html#tryLock()">tryLock</A></CODE> in interface <CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><tt>true</tt> if the lock was free and was acquired by the
current thread, or the lock was already held by the current thread; and
<tt>false</tt> otherwise.</DL>
</DD>
</DL>
<HR>
<A NAME="tryLock(long, org.apache.openjpa.lib.util.concurrent.TimeUnit)"><!-- --></A><H3>
tryLock</H3>
<PRE>
public boolean <B>tryLock</B>(long&nbsp;timeout,
<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/TimeUnit.html" title="class in org.apache.openjpa.lib.util.concurrent">TimeUnit</A>&nbsp;unit)
throws <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InterruptedException.html" title="class or interface in java.lang">InterruptedException</A></PRE>
<DL>
<DD>Acquires the lock if it is not held by another thread within the given
waiting time and the current thread has not been
<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupted</CODE></A>.
Acquires the lock if it is not held by another thread and returns
immediately with the value <tt>true</tt>, setting the lock hold count
to one. If this lock has been set to use a fair ordering policy then
an available lock <em>will not</em> be acquired if any other threads
are waiting for the lock. This is in contrast to the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ReentrantLock.html#tryLock()"><CODE>tryLock()</CODE></A>
method. If you want a timed <tt>tryLock</tt> that does permit barging on
a fair lock then combine the timed and un-timed forms together:
<pre>if (lock.tryLock() || lock.tryLock(timeout, unit) ) { ... }
</pre> If the current thread
already holds this lock then the hold count is incremented by one and
the method returns <tt>true</tt>.
If the lock is held by another thread then the
current thread becomes disabled for thread scheduling
purposes and lies dormant until one of three things happens:
<ul>
<li>The lock is acquired by the current thread; or
<li>Some other thread <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupts</CODE></A> the current
thread; or
<li>The specified waiting time elapses
</ul>
If the lock is acquired then the value <tt>true</tt> is returned and
the lock hold count is set to one. If the current thread:
<ul>
<li>has its interrupted status set on entry to this method; or
<li>is <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupted</CODE></A> while acquiring the lock,
</ul>
then <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InterruptedException.html" title="class or interface in java.lang"><CODE>InterruptedException</CODE></A> is thrown and the current thread's
interrupted status is cleared.
If the specified waiting time elapses then the value <tt>false</tt>
is returned. If the time is
less than or equal to zero, the method will not wait at all.
In this implementation, as this method is an explicit interruption
point, preference is
given to responding to the interrupt over normal or reentrant
acquisition of the lock, and over reporting the elapse of the waiting
time.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html#tryLock(long, org.apache.openjpa.lib.util.concurrent.TimeUnit)">tryLock</A></CODE> in interface <CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>timeout</CODE> - the time to wait for the lock<DD><CODE>unit</CODE> - the time unit of the timeout argument
<DT><B>Returns:</B><DD><tt>true</tt> if the lock was free and was acquired by the
current thread, or the lock was already held by the current thread; and
<tt>false</tt> if the waiting time elapsed before the lock could be
acquired.
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InterruptedException.html" title="class or interface in java.lang">InterruptedException</A></CODE> - if the current thread is interrupted
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/NullPointerException.html" title="class or interface in java.lang">NullPointerException</A></CODE> - if unit is null<DT><B>See Also:</B><DD><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>Thread.interrupt()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="unlock()"><!-- --></A><H3>
unlock</H3>
<PRE>
public void <B>unlock</B>()</PRE>
<DL>
<DD>Attempts to release this lock. If the current thread is the
holder of this lock then the hold count is decremented. If the
hold count is now zero then the lock is released. If the
current thread is not the holder of this lock then <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalMonitorStateException.html" title="class or interface in java.lang"><CODE>IllegalMonitorStateException</CODE></A> is thrown.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html#unlock()">unlock</A></CODE> in interface <CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalMonitorStateException.html" title="class or interface in java.lang">IllegalMonitorStateException</A></CODE> - if the current thread does not
hold this lock.</DL>
</DD>
</DL>
<HR>
<A NAME="newCondition()"><!-- --></A><H3>
newCondition</H3>
<PRE>
public <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A> <B>newCondition</B>()</PRE>
<DL>
<DD>Returns a <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Condition</CODE></A> instance for use with this
<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Lock</CODE></A> instance.
The returned <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Condition</CODE></A> instance supports the same
usages as do the <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang"><CODE>Object</CODE></A> monitor methods(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang"><CODE>wait</CODE></A>, <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang"><CODE>notify</CODE></A>, and <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang"><CODE>notifyAll</CODE></A>) when used with the built-in monitor lock.
<ul>
<li>If this lock is not held when any of the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Condition</CODE></A>
<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#await()"><CODE>waiting</CODE></A> or <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signal()"><CODE>signalling</CODE></A> methods are called, then an <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalMonitorStateException.html" title="class or interface in java.lang"><CODE>IllegalMonitorStateException</CODE></A> is thrown.
<li>When the condition <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#await()"><CODE>waiting</CODE></A>
methods are called the lock is released and, before they
return, the lock is reacquired and the lock hold count restored
to what it was when the method was called.
<li>If a thread is <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupt()" title="class or interface in java.lang"><CODE>interrupted</CODE></A> while
waiting then the wait will terminate, an <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/InterruptedException.html" title="class or interface in java.lang"><CODE>InterruptedException</CODE></A> will be thrown, and the thread's
interrupted status will be cleared.
<li> Waiting threads are signalled in FIFO order
<li>The ordering of lock reacquisition for threads returning
from waiting methods is the same as for threads initially
acquiring the lock, which is in the default case not specified,
but for <em>fair</em> locks favors those threads that have been
waiting the longest.
</ul>
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html#newCondition()">newCondition</A></CODE> in interface <CODE><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent">Lock</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the Condition object</DL>
</DD>
</DL>
<HR>
<A NAME="getHoldCount()"><!-- --></A><H3>
getHoldCount</H3>
<PRE>
public int <B>getHoldCount</B>()</PRE>
<DL>
<DD>Queries the number of holds on this lock by the current thread.
A thread has a hold on a lock for each lock action that is not
matched by an unlock action.
The hold count information is typically only used for testing and
debugging purposes. For example, if a certain section of code should
not be entered with the lock already held then we can assert that fact:
<pre> class X { ReentrantLock lock = new ReentrantLock(); // ...
public void m() { assert lock.getHoldCount() == 0; lock.lock(); try {
// ... method body } finally { lock.unlock(); } } }
</pre>
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the number of holds on this lock by the current thread,
or zero if this lock is not held by the current thread.</DL>
</DD>
</DL>
<HR>
<A NAME="isHeldByCurrentThread()"><!-- --></A><H3>
isHeldByCurrentThread</H3>
<PRE>
public boolean <B>isHeldByCurrentThread</B>()</PRE>
<DL>
<DD>Queries if this lock is held by the current thread.
Analogous to the <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#holdsLock(java.lang.Object)" title="class or interface in java.lang"><CODE>Thread.holdsLock(java.lang.Object)</CODE></A> method for built-in
monitor locks, this method is typically used for debugging and
testing. For example, a method that should only be called while
a lock is held can assert that this is the case:
<pre> class X { ReentrantLock lock = new ReentrantLock(); // ...
public void m() { assert lock.isHeldByCurrentThread();
// ... method body } }
</pre> It can also be used to ensure that a reentrant lock is used
in a non-reentrant manner, for example:
<pre> class X { ReentrantLock lock = new ReentrantLock(); // ...
public void m() { assert !lock.isHeldByCurrentThread(); lock.lock();
try { // ... method body } finally { lock.unlock(); } } }
</pre>
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><tt>true</tt> if current thread holds this lock and
<tt>false</tt> otherwise.</DL>
</DD>
</DL>
<HR>
<A NAME="isLocked()"><!-- --></A><H3>
isLocked</H3>
<PRE>
public boolean <B>isLocked</B>()</PRE>
<DL>
<DD>Queries if this lock is held by any thread. This method is
designed for use in monitoring of the system state,
not for synchronization control.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD><tt>true</tt> if any thread holds this lock and
<tt>false</tt> otherwise.</DL>
</DD>
</DL>
<HR>
<A NAME="isFair()"><!-- --></A><H3>
isFair</H3>
<PRE>
public final boolean <B>isFair</B>()</PRE>
<DL>
<DD>Returns true if this lock has fairness set true.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>true if this lock has fairness set true.</DL>
</DD>
</DL>
<HR>
<A NAME="getOwner()"><!-- --></A><H3>
getOwner</H3>
<PRE>
protected <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" title="class or interface in java.lang">Thread</A> <B>getOwner</B>()</PRE>
<DL>
<DD><tt>null</tt> if not owned. When this method is called by a
thread that is not the owner, the return value reflects a
best-effort approximation of current lock status. For example,
the owner may be momentarily <tt>null</tt> even if there are
threads trying to acquire the lock but have not yet done so.
This method is designed to facilitate construction of
subclasses that provide more extensive lock monitoring facilities.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the owner, or <tt>null</tt> if not owned</DL>
</DD>
</DL>
<HR>
<A NAME="hasQueuedThreads()"><!-- --></A><H3>
hasQueuedThreads</H3>
<PRE>
public final boolean <B>hasQueuedThreads</B>()</PRE>
<DL>
<DD>Queries whether any threads are waiting to acquire this lock. Note that
because cancellations may occur at any time, a <tt>true</tt>
return does not guarantee that any other thread will ever
acquire this lock. This method is designed primarily for use in
monitoring of the system state.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>true if there may be other threads waiting to acquire the lock.</DL>
</DD>
</DL>
<HR>
<A NAME="hasQueuedThread(java.lang.Thread)"><!-- --></A><H3>
hasQueuedThread</H3>
<PRE>
public final boolean <B>hasQueuedThread</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" title="class or interface in java.lang">Thread</A>&nbsp;thread)</PRE>
<DL>
<DD>Queries whether the given thread is waiting to acquire this
lock. Note that because cancellations may occur at any time, a
<tt>true</tt> return does not guarantee that this thread
will ever acquire this lock. This method is designed primarily for use
in monitoring of the system state.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>thread</CODE> - the thread
<DT><B>Returns:</B><DD>true if the given thread is queued waiting for this lock.
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/NullPointerException.html" title="class or interface in java.lang">NullPointerException</A></CODE> - if thread is null</DL>
</DD>
</DL>
<HR>
<A NAME="getQueueLength()"><!-- --></A><H3>
getQueueLength</H3>
<PRE>
public final int <B>getQueueLength</B>()</PRE>
<DL>
<DD>Returns an estimate of the number of threads waiting to
acquire this lock. The value is only an estimate because the number of
threads may change dynamically while this method traverses
internal data structures. This method is designed for use in
monitoring of the system state, not for synchronization control.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the estimated number of threads waiting for this lock</DL>
</DD>
</DL>
<HR>
<A NAME="getQueuedThreads()"><!-- --></A><H3>
getQueuedThreads</H3>
<PRE>
protected <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A> <B>getQueuedThreads</B>()</PRE>
<DL>
<DD>Returns a collection containing threads that may be waiting to
acquire this lock. Because the actual set of threads may change
dynamically while constructing this result, the returned
collection is only a best-effort estimate. The elements of the
returned collection are in no particular order. This method is
designed to facilitate construction of subclasses that provide
more extensive monitoring facilities.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the collection of threads</DL>
</DD>
</DL>
<HR>
<A NAME="hasWaiters(org.apache.openjpa.lib.util.concurrent.Condition)"><!-- --></A><H3>
hasWaiters</H3>
<PRE>
public boolean <B>hasWaiters</B>(<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A>&nbsp;condition)</PRE>
<DL>
<DD>Queries whether any threads are waiting on the given condition
associated with this lock. Note that because timeouts and
interrupts may occur at any time, a <tt>true</tt> return does
not guarantee that a future <tt>signal</tt> will awaken any
threads. This method is designed primarily for use in
monitoring of the system state.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>condition</CODE> - the condition
<DT><B>Returns:</B><DD><tt>true</tt> if there are any waiting threads.
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalMonitorStateException.html" title="class or interface in java.lang">IllegalMonitorStateException</A></CODE> - if this lock is not held
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if the given condition is
not associated with this lock
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/NullPointerException.html" title="class or interface in java.lang">NullPointerException</A></CODE> - if condition null</DL>
</DD>
</DL>
<HR>
<A NAME="getWaitQueueLength(org.apache.openjpa.lib.util.concurrent.Condition)"><!-- --></A><H3>
getWaitQueueLength</H3>
<PRE>
public int <B>getWaitQueueLength</B>(<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A>&nbsp;condition)</PRE>
<DL>
<DD>Returns an estimate of the number of threads waiting on the
given condition associated with this lock. Note that because
timeouts and interrupts may occur at any time, the estimate
serves only as an upper bound on the actual number of waiters.
This method is designed for use in monitoring of the system
state, not for synchronization control.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>condition</CODE> - the condition
<DT><B>Returns:</B><DD>the estimated number of waiting threads.
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalMonitorStateException.html" title="class or interface in java.lang">IllegalMonitorStateException</A></CODE> - if this lock is not held
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if the given condition is
not associated with this lock
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/NullPointerException.html" title="class or interface in java.lang">NullPointerException</A></CODE> - if condition null</DL>
</DD>
</DL>
<HR>
<A NAME="getWaitingThreads(org.apache.openjpa.lib.util.concurrent.Condition)"><!-- --></A><H3>
getWaitingThreads</H3>
<PRE>
protected <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A> <B>getWaitingThreads</B>(<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent">Condition</A>&nbsp;condition)</PRE>
<DL>
<DD>Returns a collection containing those threads that may be
waiting on the given condition associated with this lock.
Because the actual set of threads may change dynamically while
constructing this result, the returned collection is only a
best-effort estimate. The elements of the returned collection
are in no particular order. This method is designed to
facilitate construction of subclasses that provide more
extensive condition monitoring facilities.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>condition</CODE> - the condition
<DT><B>Returns:</B><DD>the collection of threads
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalMonitorStateException.html" title="class or interface in java.lang">IllegalMonitorStateException</A></CODE> - if this lock is not held
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if the given condition is
not associated with this lock
<DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/NullPointerException.html" title="class or interface in java.lang">NullPointerException</A></CODE> - if condition null</DL>
</DD>
</DL>
<HR>
<A NAME="toString()"><!-- --></A><H3>
toString</H3>
<PRE>
public <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>toString</B>()</PRE>
<DL>
<DD>Returns a string identifying this lock, as well as its lock
state. The state, in brackets, includes either the String
&quot;Unlocked&quot; or the String &quot;Locked by&quot;
followed by the <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#getName()" title="class or interface in java.lang"><CODE>Thread.getName()</CODE></A> of the owning thread.
<P>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A></CODE> in class <CODE><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>a string identifying this lock, as well as its lock state.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ReentrantLock.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Queue.html" title="interface in org.apache.openjpa.lib.util.concurrent"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/TimeUnit.html" title="class in org.apache.openjpa.lib.util.concurrent"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?org/apache/openjpa/lib/util/concurrent/ReentrantLock.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="ReentrantLock.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright &copy; 2006 Apache Software Foundation. All Rights Reserved.
</BODY>
</HTML>