Created
August 17, 2022 15:03
-
-
Save kylec32/0a0f132c6d207ae1d5599d905e0c3427 to your computer and use it in GitHub Desktop.
This file contains 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
public class VirtualThread { | |
public static void main(String[] args) { | |
for (int i = 0; i < 1_000_000; i++) { | |
if (i%10_000 == 0) { | |
System.out.println(i); | |
} | |
Thread.startVirtualThread(() -> { | |
try { | |
Thread.sleep(Duration.ofMinutes(10).toMillis()); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
}}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment