Why thread started by ScheduledExecutorService.schedule() never quits?
Posted
by moonese
on Stack Overflow
See other posts from Stack Overflow
or by moonese
Published on 2010-05-25T09:15:02Z
Indexed on
2010/05/25
9:21 UTC
Read the original article
Hit count: 117
java
|concurrent
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);
}
© Stack Overflow or respective owner