| Author |
Cancelling a ScheduledExecutorService
|
Sam Yim
Greenhorn
Joined: Jul 25, 2009
Posts: 17
|
|
Hi All,
I'm beginning to expirement w/ the Concurrency package.
I've setup a job to run in an interval using the ScheduledExecutorService.
The return object is ScheduledFuture, which I can use to cancel the scheduled executor service.
However, I'm not sure how to trigger a scheduledFutuer.cancel()...
I've been using 'Control C' on Windows and the kill command in UNIX to kill the job.
But I want to be able to catch these signal to ensure that the current running thread completes before the job/code is killed.
Any ideas?
Thanks.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Look at Runtime#addShutdownHook.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Sam Yim
Greenhorn
Joined: Jul 25, 2009
Posts: 17
|
|
|
Thanks. Works great.
|
 |
 |
|
|
subject: Cancelling a ScheduledExecutorService
|
|
|