Skip to content

Instantly share code, notes, and snippets.

@kylec32
Created August 17, 2022 15:03
Show Gist options
  • Save kylec32/0a0f132c6d207ae1d5599d905e0c3427 to your computer and use it in GitHub Desktop.
Save kylec32/0a0f132c6d207ae1d5599d905e0c3427 to your computer and use it in GitHub Desktop.
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