One Star

Escalate a thread from execution and run as a background job

Hi All,

I have a job with parallel execution using multithread feature for multiple clients and it will create a thread for each client and call a subjob to process the records.
And I've setup a cron to execute for every 5 mints.
Ex : In Main Job : devided all the clients into different processes
process : each process will create as many threads as based on the thread count value like below.

process1 : 10 (thread count)
thread1 --->subjob1
thread2 --->subjob2
.............................
thread10 --->subjob10

process2 :10 (thread count)

thread1 --->subjob1
thread2 --->subjob2
.............................
thread10 --->subjob10
...........................................................and so on.
Subjobs --- All the subjobs will extract the data from a db and inserts into another db.
Once the process1 finishes it's execution then only process2 starts
But because of some reason , few threads(subjobs) are taking more time to execute in process1 then process2 is waiting for it to complete it's execution.
Like this ,because of one tharead all other different threads are in waiting stage.
So I want to escalate that thread (which is taking more execution time) from the normal execution and try to run as a background job (or run in a different manner).

Environment :
TOS for DI : 5.4.1
java : 1.6
OS : Windows XP (for Dev)
OS: Ubuntu 12.04 ( for Cron)

Update :
When cron executes the job for the first 5mints process1 is taking more time and because of this reason process2 never called up,after 5 mints cron is trying to execute the same job but it will exit with the status "Job is in progress".
Suppose if the process1 completes its execution in 20 mnts then it should start process2 ,process3..like this.But instead of assigning lock to process2, it's assgning it to process1 again (new cron job will start for every 5 mints).
So the remaining processes(p2,p3..) in the cron1 are never called and every time it's executing only 10 threads of process1.How can I handle this scenario...do I need to control in os level or in job only?
I will appreciate if you guys can give me a better approach to move forward.
Thanks,
---------
Sayagoud Ravelly
3 REPLIES
Four Stars

Re: Escalate a thread from execution and run as a background job

Hi Sayagoud,
- You manage to set some context variable in your threads or may be a flag for execution status...
- Use this flag status inside if clause for controlling job execution
- You can have different instances of same job for execution based on flag values...
Try this
Vaibhav
One Star

Re: Escalate a thread from execution and run as a background job

Hi vaibhav,
Thanks for your quick response.
Currently I configured the job status(completed/in progress) details in a file for whole job not for individual instance.If I try to run the same job again, it will throw a message like job is in progress ,changing the status value back to normal once it's finish it's execution.
But the problem here is : how to run a thread(instance of a job for specific client) in background (or independently in any manner) if it's taking more time to execute.

Hi Sayagoud,
- You manage to set some context variable in your threads or may be a flag for execution status...
- Use this flag status inside if clause for controlling job execution
- You can have different instances of same job for execution based on flag values...
Try this
Vaibhav
One Star

Re: Escalate a thread from execution and run as a background job

Hi,
Can any one please suggest me a way to handle this scenario?