|
GXPARSE hosted by |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
ca.gorman.xml.parse.toolkit.Coroutine
public class Coroutine
Extends Thread
to support a coroutine thread that
shares and exchanges control with a main thread. One of the two threads is
always suspended. The active thread can suspend itself to initiate or
continue and activity in the suspended thread. The main thread invokes
yieldToCoroutine
to suspend itself and allow
the Coroutine
thread to run.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Coroutine(Runnable runnable)
Construct coroutine for a Runnable. |
Method Summary | |
---|---|
void |
invokeMain(Runnable r)
Run a command in the main thread and wait for the command to complete before control returns to the coroutine thread. |
void |
run()
Begin operation, waiting for yieldToCoroutine
to request output from the coroutine. |
void |
start()
Start coroutine and wait for it to begin running. |
void |
yieldToCoroutine()
Push a new level on callback stack and wait for callbacks from coroutine. |
void |
yieldToMain()
Pop current level from callback stack and return control to main thread. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Coroutine(Runnable runnable)
Construct coroutine for a Runnable.
NullPointerException
- if parameter is nullMethod Detail |
---|
public void start()
Start coroutine and wait for it to begin running.
start
in class Thread
IllegalThreadStateException
- when the
coroutine thread
is alive.public void run()
Begin operation, waiting for yieldToCoroutine
to request output from the coroutine.
run
in interface Runnable
run
in class Thread
IllegalStateException
- when the method is invoked from outside
the coroutine thread
.public void yieldToCoroutine() throws ListenerException, IOException
Push a new level on callback stack and wait for callbacks from coroutine.
IllegalStateException
- when the method is invoked from within the
coroutine thread
.
IllegalThreadStateException
- when the
coroutine thread
is not alive.
ListenerException
IOException
public void invokeMain(Runnable r)
Run a command in the main thread and wait for the command to complete before control returns to the coroutine thread.
NullPointerException
- if parameter is null
IllegalStateException
- when the method is invoked from outside
the coroutine thread
.public void yieldToMain()
Pop current level from callback stack and return control to main thread.
AssertionError
- when assertions are enabled and the method is
invoked from outside the coroutine thread
.
|
GXPARSE download | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |