473,387 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to make sure the record processed by one thread

I have a program with multi threads, say 2 workers. They will monitor the db
and get the records to process.

Now, I create a field, isLocked (bit) and once the record picked by either
one, it will be set to 1 (TRUE). I implement the logic at sql server stored
procedure:

1. select the records available from the table where isLocked = 0 (False)
2. select the top 1 based then available records
3. update the isLocked thread
4. return the RecordID for the Worker to process

But, how can i ensure there's no concurrency issue? I cannot ensure that
before Worker1 executing the update statement, Worker2 may run step 1
already to get the record. Therefore, both Worker1 and Worker2 would process
the record.

Any ideas to ensure only run by ONE worker?

thanks!
Nov 16 '05 #1
0 948

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: ham-z | last post by:
I have written the following Win app in VB.NET 2003 . The class is simply picture boxes that behave in a random order after they have been instantiated and added to a form. When I create 15 or more...
3
by: Mullin Yu | last post by:
I have a program with multi threads, say 2 workers. They will monitor the db and get the records to process. Now, I create a field, isLocked (bit) and once the record picked by either one, it...
4
by: Jason Kumpf | last post by:
OK I've been staring at this code all day and still with everything I have tried I cannot figure out two problems I am having. Once is why the space limit for the directory I create in the code...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
12
by: Morten Snedker | last post by:
I open a file for input. Each line is handled individually. Every time a line has been handled I wish to wait for ½ second before reading the next. Am I doing it right or wrong ? (I think it's...
11
by: PokerMan | last post by:
Hi I have a situation where a method is fired from receiving a message from my server. On receiving this message it triggers a visual animation. So what happens when the server sends say 3...
4
by: Olivier Matrot | last post by:
Hello, I have a problem with an ASP.NET 2.0 Application. A client request is processed in parrallel by two threads. This ends with the following exception : <Source>System</Source> <StackTrace...
4
by: banderson | last post by:
Hello, I am having a problem getting a new record in a subform to append to the underlying table. When I add a new record to the main form, the subform is blank, except for the ID field, which is...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.