Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8311867

StructuredTaskScope.shutdown does not interrupt newly started threads

    XMLWordPrintable

Details

    Backports

      Description

        The following doesn't complete (shutdown) in a short period of time as expected (checked on MacOS/arm64)

                for (int i = 0; i<10; i++) {
                    try (var stof = new StructuredTaskScope.ShutdownOnFailure("name", r -> Thread.ofPlatform().unstarted(r))) {
                        stof.fork(() -> {
                            Thread.sleep(Duration.ofMinutes(5));
                            return "result 2";
                        });
                        stof.fork(() -> {throw new RuntimeException("exception 1"); });
                        stof.fork(() -> {
                            Thread.sleep(Duration.ofMinutes(5));
                            return "result 3";
                        });
                        stof.join();
                    }
                }


        No problem seen if switching to Thread.ofVirtual() (and any number of iterations)

        Attachments

          Issue Links

            Activity

              People

                alanb Alan Bateman
                dbessono Dmitry Bessonov
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: