/** * Schedules the given Runnable object for a later invocation, and * returns. * An exception is thrown if the RunnableQueue was not started. * @throws IllegalStateException if getThread() is null. */ public void invokeLater(Runnable r) { if (runnableQueueThread == null) { throw new IllegalStateException ("RunnableQueue not started or has exited"); } synchronized (list) { list.push(new Link(r)); list.notify(); } }
/** * Schedules the given Runnable object for a later invocation, and * returns. * An exception is thrown if the RunnableQueue was not started. * @throws IllegalStateException if getThread() is null. */ public void invokeLater(Runnable r) { if (runnableQueueThread == null) { throw new IllegalStateException ("RunnableQueue not started or has exited"); } synchronized (list) { list.push(new Link(r)); list.notify(); } }
/** * Schedules the given Runnable object for a later invocation, and * returns. * An exception is thrown if the RunnableQueue was not started. * @throws IllegalStateException if getThread() is null. */ public void invokeLater(Runnable r) { if (runnableQueueThread == null) { throw new IllegalStateException ("RunnableQueue not started or has exited"); } synchronized (list) { list.push(new Link(r)); list.notify(); } }
/** * Waits until the given Runnable's <code>run()</code> has returned. * <em>Note: <code>invokeAndWait()</code> must not be called from the * current thread (for example from the <code>run()</code> method of the * argument).</em> * @throws IllegalStateException if getThread() is null or if the * thread returned by getThread() is the current one. */ public void invokeAndWait(Runnable r) throws InterruptedException { if (runnableQueueThread == null) { throw new IllegalStateException ("RunnableQueue not started or has exited"); } if (runnableQueueThread == Thread.currentThread()) { throw new IllegalStateException ("Cannot be called from the RunnableQueue thread"); } LockableLink l = new LockableLink(r); synchronized (list) { list.push(l); list.notify(); } l.lock(); // todo: the 'other side' of list may retrieve the l before it is locked... }
/** * Waits until the given Runnable's <code>run()</code> has returned. * <em>Note: <code>invokeAndWait()</code> must not be called from the * current thread (for example from the <code>run()</code> method of the * argument).</em> * @throws IllegalStateException if getThread() is null or if the * thread returned by getThread() is the current one. */ public void invokeAndWait(Runnable r) throws InterruptedException { if (runnableQueueThread == null) { throw new IllegalStateException ("RunnableQueue not started or has exited"); } if (runnableQueueThread == Thread.currentThread()) { throw new IllegalStateException ("Cannot be called from the RunnableQueue thread"); } LockableLink l = new LockableLink(r); synchronized (list) { list.push(l); list.notify(); } l.lock(); // todo: the 'other side' of list may retrieve the l before it is locked... }
/** * Waits until the given Runnable's <code>run()</code> has returned. * <em>Note: <code>invokeAndWait()</code> must not be called from the * current thread (for example from the <code>run()</code> method of the * argument).</em> * @throws IllegalStateException if getThread() is null or if the * thread returned by getThread() is the current one. */ public void invokeAndWait(Runnable r) throws InterruptedException { if (runnableQueueThread == null) { throw new IllegalStateException ("RunnableQueue not started or has exited"); } if (runnableQueueThread == Thread.currentThread()) { throw new IllegalStateException ("Cannot be called from the RunnableQueue thread"); } LockableLink l = new LockableLink(r); synchronized (list) { list.push(l); list.notify(); } l.lock(); // todo: the 'other side' of list may retrieve the l before it is locked... }