ini.trakem2.utils
Class TaskOnEDT<V>

java.lang.Object
  extended by ini.trakem2.utils.TaskOnEDT<V>
All Implemented Interfaces:
java.util.concurrent.Future<V>

public class TaskOnEDT<V>
extends java.lang.Object
implements java.util.concurrent.Future<V>


Constructor Summary
TaskOnEDT(java.util.concurrent.Callable<V> fn)
          The task @param fn should not be threaded; this class is intended to run small snippets of code under the event dispatch thread, while still being able to retrieve the result of the computation.
 
Method Summary
 boolean cancel(boolean mayInterruptIfRunning)
          Will only prevent execution, not interrupt it if its happening.
 V get()
           
 V get(long timeout, java.util.concurrent.TimeUnit unit)
           
 boolean isCancelled()
           
 boolean isDone()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskOnEDT

public TaskOnEDT(java.util.concurrent.Callable<V> fn)
The task @param fn should not be threaded; this class is intended to run small snippets of code under the event dispatch thread, while still being able to retrieve the result of the computation.

Method Detail

cancel

public boolean cancel(boolean mayInterruptIfRunning)
Will only prevent execution, not interrupt it if its happening.

Specified by:
cancel in interface java.util.concurrent.Future<V>
Returns:
true if the task didn't start yet.

get

public V get()
      throws java.lang.InterruptedException,
             java.util.concurrent.ExecutionException
Specified by:
get in interface java.util.concurrent.Future<V>
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

get

public V get(long timeout,
             java.util.concurrent.TimeUnit unit)
      throws java.lang.InterruptedException,
             java.util.concurrent.ExecutionException,
             java.util.concurrent.TimeoutException
Specified by:
get in interface java.util.concurrent.Future<V>
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException

isCancelled

public boolean isCancelled()
Specified by:
isCancelled in interface java.util.concurrent.Future<V>

isDone

public boolean isDone()
Specified by:
isDone in interface java.util.concurrent.Future<V>