[External] : Re: A new build and a new structured concurrency API

Eric Kolotyluk eric at kolotyluk.net
Mon Nov 15 23:33:52 UTC 2021


Okay, I was able to trick IntelliJ into running my uber-jar, but still can
just run code via normal methods...

try (var executorService = StructuredExecutor.open("",
Thread.ofVirtual().factory())) {
    IntStream.range(0, 15).forEach(item -> {
        System.out.println("item = " + item + ", Thread ID = " +
Thread.currentThread());
        executorService.fork(() -> {
            System.out.println("\ttask = " + item + ", Thread ID = " +
Thread.currentThread());
            return null;
        });
    });
}

Exception in thread "main" java.lang.IllegalStateException: Owner did not
invoke join or joinUntil
at
java.base/java.util.concurrent.StructuredExecutor.close(StructuredExecutor.java:622)
at net.kolotyluk.loom.Experiment00.main(Experiment00.java:28)

So, what is the rationale behind explicitly requiring 'join' or
'joinUntil'? Why can't close() at the end of the try-block implicitly deal
with that?

Cheers, Eric


More information about the loom-dev mailing list