Re: Call multithreaded plugin from another plugin

Posted by Ignacio Arganda-Carreras on
URL: http://imagej.273.s1.nabble.com/Call-multithreaded-plugin-from-another-plugin-tp3691048p3691052.html

Hi Mike,

I think the fields on ConnectStructuresThread class should all be
"final" to make sure you are not accessing the same memory from
different threads.

You have some examples of multithreading  in bUnwarpJ code if you want
to have a look.

Good luck!

ignacio

On Tue, Sep 22, 2009 at 11:33 AM, Michael Doube <[hidden email]> wrote:

>
> Hi all
>
> I have a plugin that I've multithreaded (Purify) that I'd like to call from another plugin.  I've already reduced the code in Purify's run() method to a call to show a dialog ( showDialog() ) and a call to a method, purify(), that calls the rest of the plugin using the variables returned by showDialog().  Purify works fine when I run it directly from the Plugins menu, but when I call it from another plugin, e.g.
>
> Purify p = new Purify();
> p.purify(important, variables).show(); //p.purify returns an ImagePlus
>
> It hangs in the middle of part of Purify that is multithreaded.  It runs properly when I run it with only 1 chunk (i.e. not multithreaded).
>
> The multithreading is done in a subclass, as in Bob Dougherty's LocalThickness, and I wonder if there is something important that I am missing when making the call to Purify's methods from another class.
>
> The code is here:
> http://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/Purify.java
>
> Cheers
>
> Mike



--
Ignacio Arganda-Carreras, Ph.D.
Institute of Neuroinformatics
Uni/ETH Zurich
Winterthurerstrasse 190
Bau 55
Zurich 8057
+41 44 63 53 031

Website: http://bioweb.cnb.csic.es/~iarganda/