Re: Plugin announcement: Parallel Super-Resolution
Posted by
Piotr Wendykier on
Jul 28, 2009; 2:12pm
URL: http://imagej.273.s1.nabble.com/Plugin-announcement-Parallel-Super-Resolution-tp3691130p3691135.html
>> This is a feature, not a bug. Some problems (killing threads, etc.)
>> appear when the user
>> decides to close the plugin while the computations are performed.
>> Therefore, the only way
>> to close the GUI is by using the Cancel button.
>
> I am no Java expert, so forgive if this is completely wrong. Whatever the
> Cancel button does can't it be also handled inside something like:
>
> public void windowClosing(WindowEvent e) {
> // stop threads and all what "Cancel" does
> }
>
> I am asking because this is also used in the Colour Threshold plugin and now I
> wonder if it is the right thing to do.
>
The Cancel button is disabled while the computations are performed,
so you would have to close ImageJ to stop the plugin. Cancel button does not
kill any threads - here is what it does:
private class CancelButtonActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
mainPanel.dispose();
ImagePlus.removeImageListener(getImageListener());
dGN = null;
fGN = null;
dGamma0 = null;
fGamma0 = null;
dInput = null;
fInput = null;
imB = null;
imX = null;
windowIDs = null;
imageTitles = null;
}
}
Here is the javadoc for java.util.concurrent.ExecutorService (which is
used in the plugin):
http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.htmlPlease see the description of shutdown() and shutdownNow() methods:
"Attempts to stop all actively executing tasks, halts the processing
of waiting tasks,
and returns a list of the tasks that were awaiting execution.
There are no guarantees beyond best-effort attempts to stop processing actively
executing tasks. For example, typical implementations will cancel via
Thread.interrupt(),
so any task that fails to respond to interrupts may never terminate."
Regards,
Piotr