| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.scijava.AbstractContextual
org.scijava.plugin.AbstractRichPlugin
org.scijava.service.AbstractService
org.scijava.thread.DefaultThreadService
public final class DefaultThreadService
Default service for managing active threads.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from interface org.scijava.thread.ThreadService | 
|---|
| ThreadService.ThreadContext | 
| Constructor Summary | |
|---|---|
| DefaultThreadService() | |
| Method Summary | ||
|---|---|---|
|  void | dispose()Performs any needed cleanup of the object's services, in preparation for the object being retired (e.g., to make garbage collection possible). | |
|  Thread | getParent(Thread thread)Returns the thread that called the specified thread. | |
|  ThreadService.ThreadContext | getThreadContext(Thread thread)Analyzes the ThreadService.ThreadContextof the given thread. | |
|  void | invoke(Runnable code)Executes the given code in a special dispatch thread, blocking until execution is complete. | |
|  boolean | isDispatchThread()Gets whether the current thread is a dispatch thread for use with ThreadService.invoke(java.lang.Runnable)andThreadService.queue(java.lang.Runnable). | |
|  Thread | newThread(Runnable r) | |
|  void | queue(Runnable code)Queues the given code for later execution in a special dispatch thread. | |
| 
 | run(Callable<V> code)Asynchronously executes the given code in a new thread, as decided by the thread service. | |
|  Future<?> | run(Runnable code)Asynchronously executes the given code in a new thread, as decided by the thread service. | |
| Methods inherited from class org.scijava.service.AbstractService | 
|---|
| getContext, initialize, registerEventHandlers, setContext, toString | 
| Methods inherited from class org.scijava.plugin.AbstractRichPlugin | 
|---|
| compareTo, getInfo, getPriority, setInfo, setPriority | 
| Methods inherited from class org.scijava.AbstractContextual | 
|---|
| context | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface org.scijava.service.Service | 
|---|
| initialize, registerEventHandlers | 
| Methods inherited from interface org.scijava.Contextual | 
|---|
| context, getContext, setContext | 
| Methods inherited from interface org.scijava.Prioritized | 
|---|
| getPriority, setPriority | 
| Methods inherited from interface java.lang.Comparable | 
|---|
| compareTo | 
| Methods inherited from interface org.scijava.plugin.HasPluginInfo | 
|---|
| getInfo, setInfo | 
| Constructor Detail | 
|---|
public DefaultThreadService()
| Method Detail | 
|---|
public <V> Future<V> run(Callable<V> code)
ThreadService
run in interface ThreadServicecode - The code to execute.
Future that will contain the result once the execution
         has finished. Call Future.get() to access to the return
         value (which will block until execution has completed).public Future<?> run(Runnable code)
ThreadService
run in interface ThreadServicecode - The code to execute.
Future that can be used to block until the execution has
         finished. Call Future.get() to do so.public boolean isDispatchThread()
ThreadServiceThreadService.invoke(java.lang.Runnable) and ThreadService.queue(java.lang.Runnable).
 In the case of AWT-based applications (e.g., Java on the desktop), this is typically the AWT Event Dispatch Thread (EDT). However, ultimately the behavior is implementation-dependent.
isDispatchThread in interface ThreadService
public void invoke(Runnable code)
            throws InterruptedException,
                   InvocationTargetException
ThreadServiceIn the case of AWT-based applications (e.g., Java on the desktop), this is typically the AWT Event Dispatch Thread (EDT). However, ultimately the behavior is implementation-dependent.
invoke in interface ThreadServicecode - The code to execute.
InterruptedException - If the code execution is interrupted.
InvocationTargetException - If an uncaught exception occurs in the
           code during execution.public void queue(Runnable code)
ThreadServiceIn the case of AWT-based applications (e.g., Java on the desktop), this is typically the AWT Event Dispatch Thread (EDT). However, ultimately the behavior is implementation-dependent.
queue in interface ThreadServicecode - The code to execute.public Thread getParent(Thread thread)
ThreadServiceThis works only on threads which the thread service knows about, of course.
getParent in interface ThreadServicethread - the managed thread, null refers to the current thread
ThreadService to spawn the
         specified threadpublic ThreadService.ThreadContext getThreadContext(Thread thread)
ThreadServiceThreadService.ThreadContext of the given thread.
getThreadContext in interface ThreadServicethread - The thread to analyze.
ThreadService.ThreadContext. Either:
         ThreadService.ThreadContext.SAME - The thread was spawned by this
         very thread service, and thus shares the same ThreadService.ThreadContext.ThreadService.ThreadContext.OTHER - The thread was spawned by a
         different thread service, and thus has a different ThreadService.ThreadContext.
         ThreadService.ThreadContext.NONE - It is unknown what spawned the
         thread, so it is effectively ThreadService.ThreadContext-free.public void dispose()
Disposable
dispose in interface Disposabledispose in class AbstractServicepublic Thread newThread(Runnable r)
newThread in interface ThreadFactory| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||