Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Background threads and maintenance applications - how to terminate them safely?



On 23/10/2007, at 11:16 AM, Miguel Arroz wrote:

So, the ideia is to override the isTerminating method, and only return true is things are safe to terminate?

No. Use that information if needed.

WOLongResponse won't solve my problem, because the user will introduce the data, get the "OK" page, close the browser and go away. I don't want him to be waiting, because, unless the whole server goes down, I'm sure, at that point, that all the data is valid and can be saved with no problems.

Fair enough. Okay, are you saving the user's data in the database prior to processing it? That would be the sensible thing to do if you want to be sure it'll still be there if the app dies.


Then just add a state column to the data that can indicate whether it's completed, in progress, etc.

Then you can safely have a background thread that dequeues jobs to process and can safely abort them mid-stream if the app has to go down.

If using WOnder, see ERXApplication.gracefulTerminate.

I'd be looking at java.util.concurrent (e.g., PriorityBlockingQueue, Execurtors, ExecutorCompletionService) etc.

with regards,
--

Lachlan Deck



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/email@hidden

This email sent to email@hidden
References: 
 >Background threads and maintenance applications - how to terminate them safely? (From: Miguel Arroz <email@hidden>)
 >Re: Background threads and maintenance applications - how to terminate them safely? (From: Lachlan Deck <email@hidden>)
 >Re: Background threads and maintenance applications - how to terminate them safely? (From: Miguel Arroz <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.