Suppose that you want to count the number of occurrences of a word in a large file. Since the operation can take a very long time, you decide to do it asynchronously in order to prevent blocking the main thread of the application.
You have the following code:
ExecutorService executor = Executors.newSingleThreadExecutor();
Callable<Integer> countWordsInFile = () -> {
int wordCount = 0;
// accessing a file and calculating wordCount
return wordCount;
};
Future<Integer> task = executor.submit(countWordsInFile);
// some other statements here
TimeUnit.SECONDS.sleep(15);
int count = task.get();What may happen when invoking get method of task (the last line)?
Select all possible cases.