Supplying a task

Report a typo

Suppose you have an instance of ExecutorService.

ExecutorService executor = Executors.newSingleThreadExecutor();

The main thread supplies two tasks to it:

Runnable task = () -> {
    try {
        TimeUnit.MILLISECONDS.sleep(1000);
        System.out.println("Hello!");
    } catch (Exception e) {
        e.printStackTrace();
    }
};

executor.submit(task);
executor.submit(task);

Select all correct statements:

Select one or more options from the list
___

Create a free account to access the full topic