-
-
Save tomi-1995/2354ced3b6349f2f8911641c2f49d9f2 to your computer and use it in GitHub Desktop.
202405_note_codes
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
// 従来のスレッド | |
Thread.ofPlatform().start(() -> { | |
sleep(5); | |
log("Platform Thread"); | |
}).join(); | |
// 仮想スレッド | |
Thread.ofVirtual().start(() -> { | |
sleep(5); | |
log("Virtual Thread"); | |
}).join(); |
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
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { | |
for (int i = 0; i < 1000000; i++) { | |
executor.submit(() -> { | |
sleep(5); | |
log("Virtual Thread"); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment