Results 1 to 4 of 4
- 06-30-2009, 04:11 PM #1
Member
- Join Date
- Jun 2009
- Posts
- 2
- Rep Power
- 0
Query regarding cancelling long run jobs
I am Calling a java standalone program through a cronjob.
In the program I have written logic that will create a CSV file.
The problem is sometimes it takes long time to create the csv file, so I need to facilitate user some way of cancelling it. User will cancel it through UI.
Can any body suggest what could be the best approach to implement it.
Also I want multi threaded approach too because many users will request to create CSV file.
Thanks
- 06-30-2009, 05:56 PM #2
Structure the job so that it periodically checks a volatile boolean variable to see if it should abort. Alternatively you could use the Thread.interrupted mechanisms. Either way, you need to manually check.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 07-01-2009, 07:07 AM #3
Member
- Join Date
- Jun 2009
- Posts
- 2
- Rep Power
- 0
Thanks for your reply.
I have tried the way you suggested by calling Thread.interrupt().
But the thread continues to run without terminating.
I read in some other forums we need to return from run() method to abort the thread.
But in my scenario in the run() method I am calling a function that will do some processing
to create CSV file
suppose
run()
{
createCSVFile();
}
Once the method createCSVFile is called how it is possible to check for a boolean flag that will return from the run() method. I want to cancel the thread when createCSVFIle() method will be called.
Please suggest
- 07-03-2009, 04:19 AM #4
If you want to use a UI, then you need only start the UI on the EDT. As far as interrupting the thread, that only sets the thread's interrupted flag unless the thread is blocking at the time of the interrupt.
During the CSV build, check the thread's interrupted flag at the end of the loop (there must be at leat one.) In the UI, you can interrupt the main thread. If you don't get an InterruptedException, that will at least set the interrupted flag.
Similar Threads
-
java jobs
By ManojK in forum Jobs DiscussionReplies: 4Last Post: 07-01-2009, 04:11 AM -
Jobs
By ruchadxt in forum Java SoftwareReplies: 0Last Post: 01-22-2009, 10:21 AM -
Java Jobs With GC sponsorship TX
By recruitness in forum Jobs OfferedReplies: 0Last Post: 12-19-2008, 10:36 PM -
Jobs
By kiko091286 in forum Jobs OfferedReplies: 1Last Post: 08-15-2008, 01:41 AM -
html jobs
By abcdefg in forum Jobs WantedReplies: 2Last Post: 04-21-2008, 05:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks