Created
November 2, 2023 22:10
-
-
Save franz1981/538367e9eaa6b490b1bf71245f8e28bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
public class Main { | |
static { | |
System.out.println("here we go..."); | |
try (ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor()) { | |
executor.submit(() -> {}).get(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
System.out.println("...fiuuu!"); | |
} | |
public static void main(String[] args) { | |
} | |
} |
What fun. I seem to have reproduced the bug here. I'll look later today
break-it Franz, that's my second name :D
So a class loader deadlock, which, by turning the runnable lambda into a proper anonymous class, won't happen anymore...
eg
static {
System.out.println("here we go...");
try (ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor()) {
executor.submit(new Runnable() {
public void run() {
}
}).get();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("...fiuuu!");
}
Might not happen any more. Your bullet, your gun, your foot.
...and all the fun, ihih
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run me on Java 21 with:
and it never completes