I was trying to follow a Java Concurrency tutorial. When I run this program, it gets stuck. Can someone help me understand why?
public class App
{
public static void main( String[] args ) {
ExecutorService executorService = Executors.newFixedThreadPool(10);
// Submit a task and accept the placeholder object for return value
Future<Integer> future = executorService.submit(new Task());
try {
Integer result = future.get();
System.out.println("Result from the task is: " + result);
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
static class Task implements Callable<Integer> {
@Override
public Integer call() {
return new Random().nextInt();
}
}
}