public class AsyncInvocation
extends java.lang.Thread
An AsyncInvocation represents the invocation of a
remote invocation that executes asynchronously from its caller. An
instanceof AsyncInvocation provides information about
the invocation such as any exception that it may have thrown.
Because it is a Thread, an
AsyncInvocation can be used as follows:
AsyncInvocation ai1 = vm.invokeAsync(Test.class, "method1");
AsyncInvocation ai2 = vm.invokeAsync(Test.class, "method2");
ai1.join();
ai2.join();
assertTrue("Exception occurred while invoking " + ai1,
!ai1.exceptionOccurred());
if (ai2.exceptionOccurred()) {
throw ai2.getException();
}
VM.invokeAsync(Class, String)| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Throwable |
exception
An exception thrown while this async invocation ran
|
java.lang.Object |
returnedObj
The returned object if any
|
| Constructor and Description |
|---|
AsyncInvocation(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Runnable work)
Creates a new
AsyncInvocation |
| Modifier and Type | Method and Description |
|---|---|
boolean |
exceptionOccurred()
Returns whether or not an exception occurred during this async
method invocation.
|
java.lang.Throwable |
getException()
Returns the exception that was thrown during this async method
invocation.
|
java.lang.String |
getMethodName()
Returns the name of the method being invoked remotely
|
java.lang.Object |
getReceiver()
Returns the receiver of this async method invocation
|
java.lang.Object |
getResult() |
java.lang.Object |
getResult(long waitTime) |
java.lang.Object |
getReturnValue() |
void |
run() |
activeCount, checkAccess, clone, 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, start, stop, stop, suspend, toString, yieldprotected volatile java.lang.Throwable exception
public volatile java.lang.Object returnedObj
public AsyncInvocation(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Runnable work)
AsyncInvocationreceiver - The object or Class on which the remote method was
invokedmethodName - The name of the method being invokedwork - The actual invocation of the methodpublic java.lang.Object getReceiver()
public java.lang.String getMethodName()
public boolean exceptionOccurred()
public java.lang.Throwable getException()
public java.lang.Object getResult()
throws java.lang.Throwable
java.lang.Throwablepublic java.lang.Object getResult(long waitTime)
throws java.lang.Throwable
java.lang.Throwablepublic java.lang.Object getReturnValue()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Thread