imagej / imagej/ImageJ

The threadpool executer in ThreadUtil prevents the JVM from exiting.

Open
#287 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
786
Forks
267
PR merge metrics
No merged PRs in 30d

Description

When tasks are called that use the ThreadUtil.threadPoolExecutor the executor prevents the jvm from exiting after the task/program has finished.

For example:

```java
import ij.process.ImageProcessor;
import ij.process.ShortProcessor;
import ij.util.ThreadUtil;

public class HoldUp {

public static void main(String[] args){
ImageProcessor proc = new ShortProcessor(256, 256);
proc.blurGaussian( 2.0 );
//ThreadUtil.threadPoolExecutor.shutdown();
}
}
```

That program will not finish unless the last line is uncommented. Some suggestions.

- Use ForkJoinPool.commonPool() it will have similar behavior but you dont have to shut it down.
- Use [ExecutorService.invokeAll](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html#invokeAll-java.util.Collection-)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with ThreadUtil.threadPoolExecutor and reproduce the issue using the HoldUp example with ImageProcessor.blurGaussian. Review the suggested ForkJoinPool.commonPool() and ExecutorService.invokeAll approaches, then establish the intended executor lifecycle. Done means the example can finish without explicitly calling shutdown, with the behavior covered by a relevant test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.