Skip to content

The threadpool executer in ThreadUtil prevents the JVM from exiting. #287

@odinsbane

Description

@odinsbane

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

For example:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions