Cannot instantiate headless - Multiple Macros Simultaneously


I created a macro that works well in Fiji pulling in a directory of images and converting/compressing into AVI files. I have many files in the directory and it only uses one logical core on my PC at a time. To decrease the long processing time I am trying to run multiple instances of ImageJ at once and having multiple macros deal with different subsets of files in the directory separately. If I open five windows of Fiji and manually click run the macro will work fine and utilize most of CPU (I cut my analysis time on a sample subset by 5x as a proof of concept). However, when I try to run multiple macros at once in headless mode I get instance errors. Here is what I did. I am assuming I am not calling the macro correctly for headless mode. Please advise. Thank you in advance for any input or advice.


I created a windows batch script to start the macro in headless mode and it works well with just once instance:

start C:\\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread1.ijm

When I add four more lines to run the four other macros (that have different files from the main directory) it comes up with the following error - see below for batch file here:

start C:\\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread1.ijm

start C:\\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread2.ijm

start C:\\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread3.ijm

start C:\\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread4.ijm

start C:\\ImageJ-win64.exe --console --headless -macro C:\Users\kmurph59\Desktop\ConvertMacro\Thread5.ijm

And for the corresponding error here after I execute the batch file. The first macro executes properly and outputs the expected data. The last four macros fail to run at all - nevermind simultaneously as I was hoping.

java.lang.RuntimeException: Cannot instantiate headless dialog except in macro mode
at net.imagej.patcher.HeadlessGenericDialog.(
at ij.gui.GenericDialog.(
at ij.gui.GenericDialog.(
at ij.macro.Functions.doDialog(
at ij.macro.Functions.getStringFunction(
at ij.macro.Interpreter.getStringTerm(
at ij.macro.Interpreter.getString(
at ij.macro.Interpreter.doStatement(
at ij.macro.Interpreter.doStatements(
at ij.plugin.Macro_Runner.runMacro(
at ij.plugin.Macro_Runner.runMacroFile(
at ij.IJ.runMacroFile(
at net.imagej.legacy.IJ1Helper$
at net.imagej.legacy.IJ1Helper$
at net.imagej.legacy.IJ1Helper.runMacroFriendly(
at net.imagej.legacy.IJ1Helper.runMacroFile(
at net.imagej.legacy.LegacyCommandline$Macro.handle(
at org.scijava.console.DefaultConsoleService.processArgs(
at org.scijava.AbstractGateway.launch(
at net.imagej.Main.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at net.imagej.launcher.ClassLauncher.launch(
at net.imagej.launcher.ClassLauncher.main(