Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;

public class Main {

    public static void main(String[] args) throws InterruptedException, ExecutionException {

        ExecutorService ex = Executors.newSingleThreadExecutor();

        Future<Integer> future =
                // This Lambda evaluated to Callable<Integer>
                ex.submit(() -> ThreadLocalRandom.current().nextInt(1, 10));

        System.out.println("Randomized value: " + future.get());

    }
}