Threading in DB update.
1 posts in topic
Flat View  Flat View

Posted By:   Dan_Smith
Posted On:   Friday, December 1, 2006 11:20 AM

I'm trying to write a program that would do a update on Database table having about 80 million records.
It would take about 5 days to process the entire table if I run single thread so I thought of running multiple threads, each thread processing small chunks of data concurrently.
But issue I'm having is, in passing selection criteria for each thread (in my case, range of sequence number) to each thread call.
I know I can't have these variables as instance variable of thread and accept it as part of constructor arguments call because all threads share/update these values.
So how would I pass my selection criteria for each thread?

Re: Threading in DB update.

Posted By:   Edward_Harned  
Posted On:   Friday, December 1, 2006 04:13 PM

Not true.

MyThread mt1 = new MyThread(this, int_start, int_end

this: so threads can find common variables.

int_start/end: these are unique for each thread you start (mt1, mt2, etc.)

The constructor of each thread saves the start and end variables as instance fields. These are unique for each thread.

You then call start on each created thread object (mt1.start(), etc.)

About | Sitemap | Contact