Reading records in a multi-threaded environment..

From: <kolli_s_at_hotmail.com>
Date: 1998/11/19
Message-ID: <7329hd$9ak$1_at_nnrp1.dejanews.com>#1/1


Hi,

I am trying to read rows from a table from different threads simutaniously. Each thread should get a different row based on some id, say, max(timestamp, begins a transaction, does some work and commits the transaction. How do I prevent other threads from reading the same thread or from blocking on read while one thread is processing a row?

Sample table 'X' looks like: (id char(10) not null, count int not null)

and there are 100 rows with counts from 1-100;

Each thread's code looks like:

begin transaction
read a row with max(count);
hold lock on max(count);
do some work;
delete the row;
commit transaction

Ideally, first thread should get hold of row with count = 100, second with count = 99 etc.. *simultaniously*.

Thanks for your time.

Please Cc: your response to "kolli_s_at_hotmail.com"

-Sudhir

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Thu Nov 19 1998 - 00:00:00 CET

Original text of this message