java.lang.Object
org.gjt.sp.util.ThreadUtilities
The threadpool of jEdit.
It uses a ExecutorService from the java.util.concurrent package.
You can run
Task
or Runnable
in it, Runnables will be
encapsulated in Task and displayed in the Task Monitor.- Since:
- jEdit 4.4pre1
- Author:
- Matthieu Casanova, Marcelo Vanzin
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
runInBackground
(Runnable runnable) Run the runnable in the threadpool.static void
runInBackground
(Task task) Run the task in the threadpool.static void
runInDispatchThread
(Runnable runnable) Run the runnable in EventDispatch Thread.static void
runInDispatchThreadAndWait
(Runnable runnable) Runs the runnable in EDT throughinvokeLater
, but returns only after the runnable is executed.static void
runInDispatchThreadNow
(Runnable runnable) Runs the runnable in EDT throughinvokeAndWait
.
-
Method Details
-
runInDispatchThread
Run the runnable in EventDispatch Thread. If the current thread is EventDispatch, it will run immediately otherwise it will be queued in the DispatchThread The difference with VFSManager.runInAWTThread() method is that this one will not wait for IO Request before being executed- Parameters:
runnable
- the runnable to run - it should return something meaningful from toString() so that we can display it in the Task Monitor.
-
runInDispatchThreadAndWait
Runs the runnable in EDT throughinvokeLater
, but returns only after the runnable is executed. This method is uninterruptible.Note the difference from
invokeAndWait
. If current thread is not EDT and there are runnables queued in EDT:- this method runs the runnable after them
invokeAndWait
runs the runnable before them
- Parameters:
runnable
- the runnable to run - it should return something meaningful from toString() so that we can display it in the Task Monitor.
-
runInDispatchThreadNow
Runs the runnable in EDT throughinvokeAndWait
. Even if the thread gets interrupted, the call does not return until the runnable finishes (uninterruptible method).This method uses
EventQueue.invokeAndWait
, so the following remark applies:If you use invokeAndWait(), make sure that the thread that calls invokeAndWait() does not hold any locks that other threads might need while the call is occurring. From the article: Threads and Swing
- Parameters:
runnable
- the runnable to run - it should return something meaningful from toString() so that we can display it in the Task Monitor.
-
runInBackground
Run the runnable in the threadpool. The runnable will be encapsulated in aTask
- Parameters:
runnable
- the runnable to run - it should return something meaningful from toString() so that we can display it in the Task Monitor.- See Also:
-
runInBackground
Run the task in the threadpool.- Parameters:
task
- the task to run
-