| <!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> |
| Condition (OpenJPA 0.9.0-incubating API) |
| </TITLE> |
| |
| <META NAME="keywords" CONTENT="org.apache.openjpa.lib.util.concurrent.Condition interface"> |
| |
| <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style"> |
| |
| <SCRIPT type="text/javascript"> |
| function windowTitle() |
| { |
| parent.document.title="Condition (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> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Condition.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ConcurrentReferenceHashSet.html" title="class in org.apache.openjpa.lib.util.concurrent"><B>PREV CLASS</B></A> |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/CopyOnWriteArrayList.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/Condition.html" target="_top"><B>FRAMES</B></A> |
| <A HREF="Condition.html" target="_top"><B>NO FRAMES</B></A> |
| <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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: FIELD | CONSTR | <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> |
| Interface Condition</H2> |
| <HR> |
| <DL> |
| <DT><PRE>public interface <B>Condition</B></DL> |
| </PRE> |
| |
| <P> |
| <tt>Condition</tt> factors out the <tt>Object</tt> 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>) into distinct objects to |
| give the effect of having multiple wait-sets per object, by |
| combining them with the use of arbitrary <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Lock</CODE></A> implementations. |
| Where a <tt>Lock</tt> replaces the use of <tt>synchronized</tt> methods |
| and statements, a <tt>Condition</tt> replaces the use of the Object |
| monitor methods. Conditions(also known as <em>condition queues</em> or |
| <em>condition variables</em>) provide a means for one thread to |
| suspend execution(to "wait") until notified by another |
| thread that some state condition may now be true. Because access |
| to this shared state information occurs in different threads, it |
| must be protected, so a lock of some form is associated with the |
| condition. The key property that waiting for a condition provides |
| is that it <em>atomically</em> releases the associated lock and |
| suspends the current thread, just like <tt>Object.wait</tt>. |
| A <tt>Condition</tt> instance is intrinsically bound to a lock. |
| To obtain a <tt>Condition</tt> instance for a particular <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Lock</CODE></A> |
| instance use its <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html#newCondition()"><CODE>newCondition()</CODE></A> method. |
| As an example, suppose we have a bounded buffer which supports |
| <tt>put</tt> and <tt>take</tt> methods. If a |
| <tt>take</tt> is attempted on an empty buffer, then the thread will block |
| until an item becomes available; if a <tt>put</tt> is attempted on a |
| full buffer, then the thread will block until a space becomes available. |
| We would like to keep waiting <tt>put</tt> threads and <tt>take</tt> |
| threads in separate wait-sets so that we can use the optimization of |
| only notifying a single thread at a time when items or spaces become |
| available in the buffer. This can be achieved using two |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Condition</CODE></A> instances. |
| <pre> class BoundedBuffer { |
| <b>final Lock lock = new ReentrantLock();</b> |
| final Condition notFull = <b>lock.newCondition(); </b> |
| final Condition notEmpty = <b>lock.newCondition(); </b> |
| final Object[] items = new Object[100]; int putptr, takeptr, count; |
| public void put(Object x) throws InterruptedException { |
| <b>lock.lock(); try {</b> while (count == items.length) |
| <b>notFull.await();</b> items[putptr] = x; |
| if (++putptr == items.length) putptr = 0; ++count; |
| <b>notEmpty.signal();</b> |
| <b>} finally { lock.unlock(); }</b> } |
| public Object take() throws InterruptedException { |
| <b>lock.lock(); try {</b> while (count == 0) |
| <b>notEmpty.await();</b> Object x = items[takeptr]; |
| if (++takeptr == items.length) takeptr = 0; --count; |
| <b>notFull.signal();</b> return x; |
| <b>} finally { lock.unlock(); }</b> } } |
| </pre> |
| |
| (The <CODE>edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue</CODE> class provides |
| this functionality, so there is no reason to implement this |
| sample usage class.) |
| A <tt>Condition</tt> implementation can provide behavior and semantics |
| that is different from that of the <tt>Object</tt> monitor methods, such as |
| guaranteed ordering for notifications, or not requiring a lock to be held |
| when performing notifications. |
| If an implementation provides such specialized semantics then the |
| implementation must document those semantics. |
| Note that <tt>Condition</tt> instances are just normal objects and can |
| themselves be used as the target in a <tt>synchronized</tt> statement, |
| and can have their own monitor <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"><CODE>wait</CODE></A> and |
| <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>notification</CODE></A> methods invoked. |
| Acquiring the monitor lock of a <tt>Condition</tt> instance, or using its |
| monitor methods, has no specified relationship with acquiring the |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Lock.html" title="interface in org.apache.openjpa.lib.util.concurrent"><CODE>Lock</CODE></A> associated with that <tt>Condition</tt> or the use of its |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#await()"><CODE>waiting</CODE></A> and <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signal()"><CODE>signalling</CODE></A> methods. |
| It is recommended that to avoid confusion you never use <tt>Condition</tt> |
| instances in this way, except perhaps within their own implementation. |
| Except where noted, passing a <tt>null</tt> value for any parameter |
| will result in a <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/NullPointerException.html" title="class or interface in java.lang"><CODE>NullPointerException</CODE></A> being thrown. |
| |
| <h3>Implementation Considerations</h3> |
| When waiting upon a <tt>Condition</tt>, a "<em>spurious |
| wakeup</em>" is permitted to occur, in |
| general, as a concession to the underlying platform semantics. |
| This has little practical impact on most application programs as a |
| <tt>Condition</tt> should always be waited upon in a loop, testing |
| the state predicate that is being waited for. An implementation is |
| free to remove the possibility of spurious wakeups but it is |
| recommended that applications programmers always assume that they can |
| occur and so always wait in a loop. The three forms of condition waiting |
| (interruptible, non-interruptible, and timed) may differ in their ease of |
| implementation on some platforms and in their performance characteristics. |
| In particular, it may be difficult to provide these features and maintain |
| specific semantics such as ordering guarantees. |
| Further, the ability to interrupt the actual suspension of the thread may |
| not always be feasible to implement on all platforms. |
| Consequently, an implementation is not required to define exactly the |
| same guarantees or semantics for all three forms of waiting, nor is it |
| required to support interruption of the actual suspension of the thread. |
| An implementation is required to |
| clearly document the semantics and guarantees provided by each of the |
| waiting methods, and when an implementation does support interruption of |
| thread suspension then it must obey the interruption semantics as defined |
| in this interface. |
| As interruption generally implies cancellation, and checks for |
| interruption are often infrequent, an implementation can favor responding |
| to an interrupt over normal method return. This is true even if it can be |
| shown that the interrupt occurred after another action may have unblocked |
| the thread. An implementation should document this behavior. |
| <P> |
| |
| <P> |
| <DL> |
| <DT><B>Since:</B></DT> |
| <DD>1.5</DD> |
| <DT><B>Author:</B></DT> |
| <DD>Doug Lea</DD> |
| </DL> |
| <HR> |
| |
| <P> |
| |
| <!-- ========== 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> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#await()">await</A></B>()</CODE> |
| |
| <BR> |
| Causes the current thread to wait until it is signalled or |
| <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> boolean</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#await(long, org.apache.openjpa.lib.util.concurrent.TimeUnit)">await</A></B>(long time, |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/TimeUnit.html" title="class in org.apache.openjpa.lib.util.concurrent">TimeUnit</A> unit)</CODE> |
| |
| <BR> |
| Causes the current thread to wait until it is signalled or interrupted, |
| or the specified waiting time elapses.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#awaitUninterruptibly()">awaitUninterruptibly</A></B>()</CODE> |
| |
| <BR> |
| Causes the current thread to wait until it is signalled.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> boolean</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#awaitUntil(java.util.Date)">awaitUntil</A></B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html" title="class or interface in java.util">Date</A> deadline)</CODE> |
| |
| <BR> |
| Causes the current thread to wait until it is signalled or interrupted, |
| or the specified deadline elapses.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signal()">signal</A></B>()</CODE> |
| |
| <BR> |
| Wakes up one waiting thread.</TD> |
| </TR> |
| <TR BGCOLOR="white" CLASS="TableRowColor"> |
| <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
| <CODE> void</CODE></FONT></TD> |
| <TD><CODE><B><A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signalAll()">signalAll</A></B>()</CODE> |
| |
| <BR> |
| Wakes up all waiting threads.</TD> |
| </TR> |
| </TABLE> |
| |
| <P> |
| |
| <!-- ============ 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="await()"><!-- --></A><H3> |
| await</H3> |
| <PRE> |
| void <B>await</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>Causes the current thread to wait until it is signalled or |
| <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>. |
| The lock associated with this <tt>Condition</tt> is atomically |
| released and the current thread becomes disabled for thread scheduling |
| purposes and lies dormant until <em>one</em> of four things happens: |
| <ul> |
| <li>Some other thread invokes the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signal()"><CODE>signal()</CODE></A> method for this |
| <tt>Condition</tt> and the current thread happens to be chosen as the |
| thread to be awakened; or |
| <li>Some other thread invokes the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signalAll()"><CODE>signalAll()</CODE></A> method for this |
| <tt>Condition</tt>; 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, and interruption of thread suspension is supported; or |
| <li>A "<em>spurious wakeup</em>" occurs |
| </ul> In all cases, before this method can return the current thread must |
| re-acquire the lock associated with this condition. When the |
| thread returns it is <em>guaranteed</em> to hold this lock. |
| 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 waiting |
| and interruption of thread suspension is supported, |
| </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. It is not specified, in the first |
| case, whether or not the test for interruption occurs before the lock |
| is released. |
| |
| <b>Implementation Considerations</b> |
| The current thread is assumed to hold the lock associated with this |
| <tt>Condition</tt> when this method is called. |
| It is up to the implementation to determine if this is |
| the case and if not, how to respond. Typically, an exception will be |
| thrown(such as <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>) and the |
| implementation must document that fact. |
| An implementation can favor responding to an interrupt over normal |
| method return in response to a signal. In that case the implementation |
| must ensure that the signal is redirected to another waiting thread, if |
| there is one. |
| <P> |
| <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(and |
| interruption of thread suspension is supported).</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="awaitUninterruptibly()"><!-- --></A><H3> |
| awaitUninterruptibly</H3> |
| <PRE> |
| void <B>awaitUninterruptibly</B>()</PRE> |
| <DL> |
| <DD>Causes the current thread to wait until it is signalled. |
| The lock associated with this condition is atomically |
| released and the current thread becomes disabled for thread scheduling |
| purposes and lies dormant until <em>one</em> of three things happens: |
| <ul> |
| <li>Some other thread invokes the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signal()"><CODE>signal()</CODE></A> method for this |
| <tt>Condition</tt> and the current thread happens to be chosen as the |
| thread to be awakened; or |
| <li>Some other thread invokes the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signalAll()"><CODE>signalAll()</CODE></A> method for this |
| <tt>Condition</tt>; or |
| <li>A "<em>spurious wakeup</em>" occurs |
| </ul> In all cases, before this method can return the current thread must |
| re-acquire the lock associated with this condition. When the |
| thread returns it is <em>guaranteed</em> to hold this lock. |
| If the current thread's interrupted status is set when it enters |
| this method, or it 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, it will continue to wait until signalled. When it finally |
| returns from this method its interrupted status will still be set. |
| |
| <b>Implementation Considerations</b> |
| The current thread is assumed to hold the lock associated with this |
| <tt>Condition</tt> when this method is called. |
| It is up to the implementation to determine if this is |
| the case and if not, how to respond. Typically, an exception will be |
| thrown(such as <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>) and the |
| implementation must document that fact. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="await(long, org.apache.openjpa.lib.util.concurrent.TimeUnit)"><!-- --></A><H3> |
| await</H3> |
| <PRE> |
| boolean <B>await</B>(long time, |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/TimeUnit.html" title="class in org.apache.openjpa.lib.util.concurrent">TimeUnit</A> 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>Causes the current thread to wait until it is signalled or interrupted, |
| or the specified waiting time elapses. This method is behaviorally |
| equivalent to:<br> |
| <pre> awaitNanos(unit.toNanos(time)) > 0 |
| </pre> |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>time</CODE> - the maximum time to wait<DD><CODE>unit</CODE> - the time unit of the <tt>time</tt> argument. |
| <DT><B>Returns:</B><DD><tt>false</tt> if the waiting time detectably elapsed |
| before return from the method, else <tt>true</tt>. |
| <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(and |
| interruption of thread suspension is supported).</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="awaitUntil(java.util.Date)"><!-- --></A><H3> |
| awaitUntil</H3> |
| <PRE> |
| boolean <B>awaitUntil</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html" title="class or interface in java.util">Date</A> deadline) |
| 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>Causes the current thread to wait until it is signalled or interrupted, |
| or the specified deadline elapses. |
| The lock associated with this condition is atomically |
| released and the current thread becomes disabled for thread scheduling |
| purposes and lies dormant until <em>one</em> of five things happens: |
| <ul> |
| <li>Some other thread invokes the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signal()"><CODE>signal()</CODE></A> method for this |
| <tt>Condition</tt> and the current thread happens to be chosen as the |
| thread to be awakened; or |
| <li>Some other thread invokes the <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/Condition.html#signalAll()"><CODE>signalAll()</CODE></A> method for this |
| <tt>Condition</tt>; 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, and interruption of thread suspension is supported; or |
| <li>The specified deadline elapses; or |
| <li>A "<em>spurious wakeup</em>" occurs. |
| </ul> In all cases, before this method can return the current thread must |
| re-acquire the lock associated with this condition. When the |
| thread returns it is <em>guaranteed</em> to hold this lock. |
| 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 waiting |
| and interruption of thread suspension is supported, |
| </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. It is not specified, in the first |
| case, whether or not the test for interruption occurs before the lock |
| is released. |
| The return value indicates whether the deadline has elapsed, |
| which can be used as follows: |
| <pre> synchronized boolean aMethod(Date deadline) { |
| boolean stillWaiting = true; while (!conditionBeingWaitedFor) { |
| if (stillWaiting) stillWaiting = theCondition.awaitUntil(deadline); else |
| return false; } // ... } |
| </pre> |
| |
| <b>Implementation Considerations</b> |
| The current thread is assumed to hold the lock associated with this |
| <tt>Condition</tt> when this method is called. |
| It is up to the implementation to determine if this is |
| the case and if not, how to respond. Typically, an exception will be |
| thrown(such as <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>) and the |
| implementation must document that fact. |
| An implementation can favor responding to an interrupt over normal |
| method return in response to a signal, or over indicating the passing |
| of the specified deadline. In either case the implementation |
| must ensure that the signal is redirected to another waiting thread, if |
| there is one. |
| <P> |
| <DD><DL> |
| <DT><B>Parameters:</B><DD><CODE>deadline</CODE> - the absolute time to wait until |
| <DT><B>Returns:</B><DD><tt>false</tt> if the deadline has |
| elapsed upon return, else <tt>true</tt>. |
| <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(and |
| interruption of thread suspension is supported).</DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="signal()"><!-- --></A><H3> |
| signal</H3> |
| <PRE> |
| void <B>signal</B>()</PRE> |
| <DL> |
| <DD>Wakes up one waiting thread. |
| If any threads are waiting on this condition then one |
| is selected for waking up. That thread must then re-acquire the |
| lock before returning from <tt>await</tt>. |
| <P> |
| <DD><DL> |
| </DL> |
| </DD> |
| </DL> |
| <HR> |
| |
| <A NAME="signalAll()"><!-- --></A><H3> |
| signalAll</H3> |
| <PRE> |
| void <B>signalAll</B>()</PRE> |
| <DL> |
| <DD>Wakes up all waiting threads. |
| If any threads are waiting on this condition then they are |
| all woken up. Each thread must re-acquire the lock before it can |
| return from <tt>await</tt>. |
| <P> |
| <DD><DL> |
| </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> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
| <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Condition.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
| <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
| </TR> |
| </TABLE> |
| </TD> |
| <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
| </EM> |
| </TD> |
| </TR> |
| |
| <TR> |
| <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/ConcurrentReferenceHashSet.html" title="class in org.apache.openjpa.lib.util.concurrent"><B>PREV CLASS</B></A> |
| <A HREF="../../../../../../org/apache/openjpa/lib/util/concurrent/CopyOnWriteArrayList.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/Condition.html" target="_top"><B>FRAMES</B></A> |
| <A HREF="Condition.html" target="_top"><B>NO FRAMES</B></A> |
| <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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> |
| <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
| DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> |
| </TR> |
| </TABLE> |
| <A NAME="skip-navbar_bottom"></A> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| |
| <HR> |
| Copyright © 2006 Apache Software Foundation. All Rights Reserved. |
| </BODY> |
| </HTML> |