[ImageJ-devel] ImageJ2 plugin thread question
Yili Zhao
panovr at gmail.com
Thu Feb 13 08:19:39 CST 2014
Hi,
if I want to develop a plugin for ImageJ2, there are basically two kinds
of plugin:
1. first kind plugin does not need GUI;
2. second kind plugin does need GUI.
Suppose this plugin will perform a long time-consumed task, so I want to
ask that:
1. will ImageJ2 run its plugin in a new thread? Because in Swing toolkit,
all UI events should be processed in UI thread or the main thread, and
there is only One UI thread, so it is a single thread model.
Running a plugin in a new thread can guarantee the plugin will not block
ImageJ2's GUI.
2. If this plugin need its own GUI, but this plugin is running in a
thread which is not the UI thread (event dispatch thread), and this
plugin's GUI should be created in UI thread for thread safe, how can this
be done?
In order to avoid blocking the ImageJ2' user interface, I plan to do like
this:
1. execute the "long time-consumed task" in a separate worker thread;
2. In the task running process, I want to report the running progress to
the ImageJ2 main frame, so that the main frame can display a progress
information to let user know the current status;
3. When the task completed, it can notify the main frame, and the main
frame can response to this event.
How can I implement this asynchronous task model in ImageJ2? (I think
maybe I need some helper classes like "SwingWorker" in JDK 6)
Thanks!
--
Yili Zhao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20140213/34bbbf12/attachment.html>
More information about the ImageJ-devel
mailing list