ini.trakem2.utils
Class Bureaucrat

java.lang.Object
  extended by java.lang.Thread
      extended by ini.trakem2.utils.Bureaucrat
All Implemented Interfaces:
java.lang.Runnable

public class Bureaucrat
extends java.lang.Thread

Sets a Worker thread to work, and waits until it finishes, blocking all user interface input until then, except for zoom and pan, for all given projects.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
 boolean addPostTask(java.lang.Runnable task)
          Add a task to run after the Worker has finished or quit.
static Bureaucrat create(Worker worker, Project project)
          Creates but does not start the Bureaucrat thread.
static Bureaucrat create(Worker worker, Project[] project)
          Creates but does not start the Bureaucrat thread.
static Bureaucrat createAndStart(Worker worker, Project project)
          Creates and start the Bureaucrat thread.
static Bureaucrat createAndStart(Worker worker, Project[] project)
          Creates and start the Bureaucrat thread.
 java.lang.String getTaskName()
          Returns the task the worker is currently executing, which may change over time.
 Worker getWorker()
           
 void goHaveBreakfast()
          Starts the Bureaucrat thread: sets the worker to work and monitors it until it finishes.
 boolean isActive()
           
 void quit()
          Waits until worker finishes before returning.
 void run()
           
 
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, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static Bureaucrat create(Worker worker,
                                Project project)
Creates but does not start the Bureaucrat thread.


create

public static Bureaucrat create(Worker worker,
                                Project[] project)
Creates but does not start the Bureaucrat thread.


createAndStart

public static Bureaucrat createAndStart(Worker worker,
                                        Project project)
Creates and start the Bureaucrat thread.


createAndStart

public static Bureaucrat createAndStart(Worker worker,
                                        Project[] project)
Creates and start the Bureaucrat thread.


goHaveBreakfast

public void goHaveBreakfast()
Starts the Bureaucrat thread: sets the worker to work and monitors it until it finishes.


run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getTaskName

public java.lang.String getTaskName()
Returns the task the worker is currently executing, which may change over time.


quit

public void quit()
Waits until worker finishes before returning. Calls quit() on the Worker and interrupt() on each threads in this ThreadGroup and subgroups.


isActive

public boolean isActive()

getWorker

public Worker getWorker()

addPostTask

public boolean addPostTask(java.lang.Runnable task)
Add a task to run after the Worker has finished or quit. Does not accept more tasks once the Worker no longer runs.