Login  Register

Re: Pause/resume macro?

Posted by Michael Schmid on Apr 30, 2017; 6:12pm
URL: http://imagej.273.s1.nabble.com/Pause-resume-macro-tp5001108p5018644.html

Hi LP,

in some cases, you can do other things in ImageJ while a macro is
running, but in general this is not a safe way of working.
In principle you could write a short plugin or Javascript that suspends
the thread of the currently running macro or all running macros (all
threads whose names start with "Run$"), and resume the thread(s) later.
This is NOT a safe way of operation! Your 'do something else' operation
may leave ImageJ in a state that is different from what the macro
expects. For non-Batch-mode macros, already selecting a new foreground
image will usually make them work in an unintended way, not to mention
changes of ImageJ settings.
Also some operations may fail if they are suspended in one thread, and
another thread uses the same type of operation. In other words, there is
still some code in ImageJ1 and in many ImageJ1 plugins that does not
work correctly with multithreading (e.g. use of static class variables
as parameters, having them static to save their values as defaults for
the next invocation of the command). This is problem remains if one of
the threads is suspended.

So, the only safe way of doing something else while a macro is running
is starting another instance of ImageJ. Depending on the operating
system, you may have an Edit>Options>Misc 'Run Single-Instance Listener'
option that you can disable. Also starting ij.jar from the command line
can give you a new instance of ImageJ. If CPU load is an issue, on
Unix-like operating systems, you may suspend the process of the ImageJ
instance running the macro, and resume it later:
   kill -TSTP processID
   kill -CONT processID
where processID is the PID of ImageJ as you get it via 'ps'


Michael
________________________________________________________________

On 2017-04-30 18:33, LP wrote:

> Dear All,
>
> I think that John Oreopoulos (Dec 11, 2012) had a very good question:
>
> Can we pause a macro at an arbitrary moment so we can do something
> else, and
> then resume the macro later?
>
> This topic has more than 2370 views so I assume that many people
> wondered
> the same thing.
>
>
> Thank you
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html