JEP 477: println blocking
Adam Sotona
adam.sotona at oracle.com
Mon Sep 23 05:42:52 UTC 2024
Hi,
I’m updating my classroom examples to run on JDK 23 and with IO.println I experience different behavior than with System.out.println. Following example explains the issue.
Thank you,
Adam
static void doSomething() {
try {
Thread.sleep(1000);
} catch (InterruptedException ignore) {}
}
void main() {
Thread.ofVirtual().start(() -> {
while (true) {
doSomething();
System.out.println("I do something until you press Enter");
}
});
Thread.ofVirtual().start(() -> {
while (true) {
doSomething();
println("I'm blocked until you press Enter");
}
});
readln("");
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240923/b0090dd2/attachment-0001.htm>
More information about the amber-dev
mailing list