From the course: Advanced Java: Threads and Concurrency
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Ways to create virtual threads - Java Tutorial
From the course: Advanced Java: Threads and Concurrency
Ways to create virtual threads
- [Instructor] Virtual threads was a preview feature since Java 19, and has become a fully fledged feature since Java 21. So to work with virtual threads, you should use Java 19 or later. If you happen to be using Java 19 or 20, remember to set the --enable-preview flag when compiling and running your code. As most of you are using IDEs, you might need to make a few project settings and compiler settings, and specify that you need to use preview features of the Java version that you are using. For instance, in IntelliJ in Settings, you click here and go to Settings, and find Java Compiler like this. You might want to specify the --enable-preview flag as an additional command line parameter right here, --enable-preview. And in your project settings, that is go to Project Structure, and right here set the language level to use preview features. Right here, preview features. And in run configurations, click here, the three dots. Go to Edit. Add --enable-preview as a VM option by clicking…