gov.bnl.star.offline.scheduler.util
Class Task

java.lang.Object
  extended by java.lang.Thread
      extended by gov.bnl.star.offline.scheduler.util.Task
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
CatalogTask, CommandLineTask, CSHCommandLineTask

public class Task
extends java.lang.Thread

A task that is going to be executed in a separate thread while displaying a character every second on the standard output.

Version:
$Revision: 1.9 $ $Date: 2006/11/21 00:41:29 $
Author:
Gabriele Carcassi

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  int exitStatus
          The exit status of the process.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Task()
          A new task to be executed in background.
Task(char waitingDot)
          A new task to be executed in background.
Task(char waitingDot, int msTimeout)
          A new task to be executed in background with a timeout.
Task(int msTimeout)
          A new task to be executed in background with a timeout.
 
Method Summary
 void execute()
          Starts the task and wait for the result.
 int getExitStatus()
          Returns the condition on which the task finished.
 
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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

exitStatus

protected int exitStatus
The exit status of the process.

Constructor Detail

Task

public Task()
A new task to be executed in background. The character displayed while waiting will be a '.'


Task

public Task(char waitingDot)
A new task to be executed in background. The character displayed while waiting will be the one specified

Parameters:
waitingDot - character to display every second while waiting for the task to finish

Task

public Task(int msTimeout)
A new task to be executed in background with a timeout. If after the timeout the task hasn't finished it will be considered as failed.

Parameters:
msTimeout - timeout in milliseconds

Task

public Task(char waitingDot,
            int msTimeout)
A new task to be executed in background with a timeout. The character displayed while waiting will be the one specified. If after the timeout the task hasn't finished it will be considered as failed. The

Parameters:
waitingDot - character to display every second while waiting for the task to finish
msTimeout - timeout in milliseconds
Method Detail

getExitStatus

public int getExitStatus()
Returns the condition on which the task finished. Return value 0 means no errors.

Returns:
for success 0, else for failure

execute

public void execute()
Starts the task and wait for the result. While waiting, some dots are displayed to give the user the impression that the job didn't hang.



Copyright © 2002-2004 STAR collaboration - Brookhaven National Laboratory. All Rights Reserved.