Why thread started by ScheduledExecutorService.schedule() never quits?
- by moonese
If I create a scheduled task by calling ScheduledExecutorService.schedule(), it never quits after execution, is it a JDK bug, or I just miss something?
note: doSomething() is empty method below.
public static void doSomething() {
}
public static void main(String[] args) {
ScheduledFuture scheduleFuture =
Executors.newSingleThreadScheduledExecutor().schedule(new Callable() {
public Void call() {
try {
doSomething();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}, 1, TimeUnit.SECONDS);
}