Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #22536
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2013-02-26 08:09 -0800 |
| References | <7024d5a0-10c2-41db-bd72-85d03c3feae6@googlegroups.com> <5w697krlf571$.1hwa9p5it81zl.dlg@40tude.net> |
| Message-ID | <55b9dfa9-2e79-4e42-b5fb-de6a44db9188@googlegroups.com> (permalink) |
| Subject | Re: Concurrency and restarting tasks |
| From | me 2 <winona_whitener@yahoo.com> |
On Tuesday, February 26, 2013 9:58:28 AM UTC-5, Joerg Meier wrote: > On Tue, 26 Feb 2013 06:32:28 -0800 (PST), me 2 wrote: > > > > > I have an interesting (to me at least!) puzzle. > > > > > I have a task that can take a long time that I need to run periodically. I want to be able to cancel the execution of that task. I've been looking at the Scheduler and Future objects, but I haven't seen how to cleanly stop, wait for a couple of seconds and restart the task on schedule. And my task won't always take X seconds--sometimes it will generate exceptions or take longer or shorter or any number of other things. > > > > > There are plenty of examples that show the first steps--setting up the schedule and canceling. Restarting apparently is not as common. > > > > As I understand, ThreadS are simply not made to be resumed after being > > cancelled. What you want might simply not be possible. That being said, it > > shouldn't be too hard to simply make a new Thread with your Runnable and > > start that instead of restarting the cancelled one. > > > > Alternatively, you can make your long running task somehow check for a > > volatile flag and pause if it's set to something. > > > > Liebe Gruesse, > > Joerg > > > > -- > > Ich lese meine Emails nicht, replies to Email bleiben also leider > > ungelesen. Hey, I suppose you are right. That doesn't make much sense when you put it like that. The problem is that I need an event to fire if the task doesn't complete in X seconds. I guess I don't really care about canceling the thread--just getting the event to fire and then getting set up to attempt the task again. The double setup with the two scheduled tasks--one to start and one to cancel--gets muddled after like the 4th iteration. Hmmm.... I'll keep looking. Me
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Concurrency and restarting tasks me 2 <winona_whitener@yahoo.com> - 2013-02-26 06:32 -0800
Re: Concurrency and restarting tasks Roedy Green <see_website@mindprod.com.invalid> - 2013-02-26 06:47 -0800
Re: Concurrency and restarting tasks Joerg Meier <joergmmeier@arcor.de> - 2013-02-26 15:58 +0100
Re: Concurrency and restarting tasks me 2 <winona_whitener@yahoo.com> - 2013-02-26 08:09 -0800
Re: Concurrency and restarting tasks Joerg Meier <joergmmeier@arcor.de> - 2013-02-26 18:14 +0100
csiph-web