Facing problem executing the loom code.

Ron Pressler ron.pressler at oracle.com
Sun Aug 23 18:07:41 UTC 2020


Hi.

The language level doesn’t matter, but you must use the special Loom 
Early Access JDK available here: 

    http://jdk.java.net/loom/

You should then set your IDE to use that special JDK for your project.


- Ron


On 23 August 2020 at 16:51:05, Priyanka Thakur (priyanka.thakur at knoldus.com(mailto:priyanka.thakur at knoldus.com)) wrote:

> Hi,
> I want to discuss the how can I execute the Loom code on My machine.
> This is my source file.
>  
> import java.util.concurrent.ExecutorService;
> import java.util.concurrent.Executors;
> import java.util.concurrent.Callable;
>  
> public class MainClass {
>  
> public static void main(String[] args) {
> try (ExecutorService executor = Executors.newVirtualThreadExecutor()) {
> executor.submit(() -> foo());
> executor.submit(() -> bar());
> }
> }
>  
> static void foo() {
> try (ExecutorService executor = Executors.newVirtualThreadExecutor()) {
> Callable callableTask = () -> {
> //TimeUnit.MILLISECONDS.sleep(300);
> return "Task's execution 1";
> };
> executor.submit(callableTask);
> }
> }
>  
> static void bar() {
> try (ExecutorService executor = Executors.newVirtualThreadExecutor()) {
> Callable callableTask = () -> {
> // TimeUnit.MILLISECONDS.sleep(300);
> return "Task's execution 2";
> };
> executor.submit(callableTask);
> }
>  
> }
> }
>  
>  
> I am executing this code in the IntelliJ.
>  
> Project SDK is set to java 16.
> Project language level is set to x-experimental features as 16 was not
> available.
>  
> I am able to resolve the project. But when I try to execute the code I got
> the following error.
>  
>  
>  
> *Error:(8, 50) java: cannot find symbol symbol: method
> newVirtualThreadExecutor() location: class java.util.concurrent.Executors*
>  
> Please tell me where I am wrong.
> --
> Thanks and Regards
>  
> *Priyanka Thakur*
> Software Consultant
> Knoldus Inc.  
> +91-9911676745
> Canada - USA - India - Singapore
>  
>  
>  
> --
> Your feedback matters - At Knoldus we aim to be very professional in our
> quality of work, commitment to results, and proactive communication. If you
> feel otherwise please share your feedback
> and we would work on it.  



More information about the loom-dev mailing list