Package org.apache.tools.ant.util
Class WorkerAnt
- java.lang.Object
- 
- java.lang.Thread
- 
- org.apache.tools.ant.util.WorkerAnt
 
 
- 
- All Implemented Interfaces:
- java.lang.Runnable
 
 public class WorkerAnt extends java.lang.ThreadA worker ant executes a single task in a background thread. After the run, any exception thrown is turned into a BuildException, which can be rethrown, the finished attribute is set, then notifyAll() is called, so that anyone waiting on the same notify object gets woken up.This class is effectively a superset of org.apache.tools.ant.taskdefs.Parallel.TaskRunnable- Since:
- Ant 1.8
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringERROR_NO_TASKError message if invoked with no task
 - 
Method SummaryModifier and Type Method Description BuildExceptiongetBuildException()Get any build exception.java.lang.ThrowablegetException()Get whatever was thrown, which may or may not be a buildException.TaskgetTask()Get the taskbooleanisFinished()Query the task/thread for being finished.voidrethrowAnyBuildException()Raise an exception if one was caughtvoidrun()Run the task, which is skipped if null.voidwaitUntilFinished(long timeout)Block on the notify object and so wait until the thread is finished.- 
Methods inherited from class java.lang.ThreadactiveCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
 
- 
 
- 
- 
- 
Field Detail- 
ERROR_NO_TASKpublic static final java.lang.String ERROR_NO_TASK Error message if invoked with no task- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
WorkerAntpublic WorkerAnt(Task task, java.lang.Object notify) Create the worker.This does not start the thread, merely configures it. - Parameters:
- task- the task
- notify- what to notify
 
 - 
WorkerAntpublic WorkerAnt(Task task) Create the worker, using the worker as the notification point.This does not start the thread, merely configures it. - Parameters:
- task- the task
 
 
- 
 - 
Method Detail- 
getBuildExceptionpublic BuildException getBuildException() Get any build exception. This would seem to be oversynchronised, but know that Java pre-1.5 can reorder volatile access. The synchronized attribute is to force an ordering.- Returns:
- the exception or null
 
 - 
getExceptionpublic java.lang.Throwable getException() Get whatever was thrown, which may or may not be a buildException. Assertion: getException() instanceof BuildException <=> getBuildException()==getException()- Returns:
- the exception.
 
 - 
getTaskpublic Task getTask() Get the task- Returns:
- the task
 
 - 
isFinishedpublic boolean isFinished() Query the task/thread for being finished. This would seem to be oversynchronised, but know that Java pre-1.5 can reorder volatile access. The synchronized attribute is to force an ordering.- Returns:
- true if the task is finished.
 
 - 
waitUntilFinishedpublic void waitUntilFinished(long timeout) throws java.lang.InterruptedExceptionBlock on the notify object and so wait until the thread is finished.- Parameters:
- timeout- timeout in milliseconds
- Throws:
- java.lang.InterruptedException- if the execution was interrupted
 
 - 
rethrowAnyBuildExceptionpublic void rethrowAnyBuildException() Raise an exception if one was caught- Throws:
- BuildException- if one has been picked up
 
 - 
runpublic void run() Run the task, which is skipped if null. When invoked again, the task is re-run.- Specified by:
- runin interface- java.lang.Runnable
- Overrides:
- runin class- java.lang.Thread
 
 
- 
 
-