P Rao

Greenhorn
+ Follow
since Aug 05, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by P Rao

Hi,
I have a job processing application that will be running in a cluster, hence multiple JVMs. The Jobs will be sitting in a database and a scheduler will wake up every x seconds loads a job, has to update the row with a processing flag (so other thread will not load and process the same job).
So I added a special state field that can be "NEW", "PROCESSING" and "COMPLETED"
When the state of a job is "NEW", the job can be grabbed from the database by one of the threads and the field of that object will be set to "PROCESSING" so that other threads will not load the same job. BUT how can I ensure that in case of similtaniouse access and before the state change, 2 threads will not grab the same job. what is the best way to tackle this problem?

Thanks,