threading taking loong time to process
807580Sep 2 2009 — edited Sep 5 2009Hi Gurus,
I have a class which reads the file and send the record to separate classes to process that record. so:
|------ wclass1
|
|
|------ wclass2
|
|
mainclass |------ wclass3
|
|
|------ wclass4
|
|
|------ wclass5
so at the moment, mainclass calls wclass1.process(String record), wclass2.process(String record),... one after another.
I tried to make the wclass1,2..4 a Runnable and had a following loop in mainclass to check each wlcassx thread by updating a flag to see if the wclassx.process(String record) finished processing the current record so i can send the next record to process. But my threading didnt work.
while(true)
{
boolean recordProcessed = false;
for (int i = 0; i < tables.size(); i++)
{
recordProcessed = ((Extractor) tables.elementAt(i)).recordProcessed();
if(!recordProcessed)
{
break;
}
}
if(recordProcessed) break;
}
Please tell me the best to thread it.
Thanks a BUNCH