I have this code:
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Boolean> f = executor.submit(() -> {
    if (true) {
        while (true);
    }
    return false;
});
try {
    System.out.println(f.get(10, TimeUnit.MILLISECONDS));
}
catch (InterruptedException | ExecutionException | TimeoutException e) {
    throw e;
}
While I'm running the program, I get the Exception like I should, but the while loop continues to run and the program does not stop.
I tried executor.shutdown(), executor.shutdownNow(), f.cancel(true) and more.
Does anyone have any idea? I'm trying to solve this for three days.
 
     
    