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 |
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/ |
In reply to this post by Michael Doube
Michael Doube 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). If there is an Exception stack trace, please print it here. If there isn't (thread lock up), launch the JVM from a command line and, when it hangs, push control+\ (control backslash) on the command line, and paste us here the entire set of stack traces (one per thread). Albert |
In reply to this post by Michael Doube
Hi Michael,
it seems that you are using global variables (class variables) that are not set if you don't call showDialog. E.g., getChunkRanges uses slicesPerChunk; but there are more. Michael ________________________________________________________________ On 22 Sep 2009, at 11:33, Michael Doube 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 |
Michael, Wayne, Ignacio, Albert
I fixed my code with a combination of your suggestions, and following the Fiji design guidelines, http://pacific.mpi-cbg.de/wiki/index.php/PlugIn_Design_Guidelines Mike Michael Schmid wrote: > Hi Michael, > > it seems that you are using global variables (class variables) that > are not set if you don't call showDialog. E.g., getChunkRanges uses > slicesPerChunk; but there are more. > > Michael > ________________________________________________________________ > > On 22 Sep 2009, at 11:33, Michael Doube 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 >> -- Dr Michael Doube BPhil BVSc PhD MRCVS Research Associate Department of Bioengineering Imperial College London South Kensington Campus London SW7 2AZ United Kingdom |
Free forum by Nabble | Edit this page |