Jay Roy
asked on
dividing data among threads
hi guys
Needed some help with code
I have this so far
so for Thread1 i will have
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin Count, endCount);
beginCount =0 and endCount = 12000
Thread2
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin Count, endCount);
beginCount =1200 and endCount = 2400
Thread3
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin Count, endCount);
beginCount =2400 and endCount = 3600
Thread4
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin Count, endCount);
beginCount =3600 and endCount = 4800
Thread5
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin Count, endCount);
beginCount =4800 and endCount = 6000
How can i modify my beginCount and endCount within my for loop?
Any help will be greatly appreciated
Thanks
Needed some help with code
I have this so far
int numberOfThreads = 5;
for(int i=0; i < numberOfThreads; i++){
Callable<List<CustomerVO>> task = new Callable<List<CustomerVO>>(){
public List<CustomerVO> call(){
String rowCount = executeQuery("select count(*) from CUSTOMER"); //returns 6000
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList())
.subList(beginCount, endCount);
return resultList;
}
};
processMemory(resultList);
}
//my requirment is if rowCount returns 6000 rows i want to distribute it among the 5 threads in the forloop.so for Thread1 i will have
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin
beginCount =0 and endCount = 12000
Thread2
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin
beginCount =1200 and endCount = 2400
Thread3
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin
beginCount =2400 and endCount = 3600
Thread4
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin
beginCount =3600 and endCount = 4800
Thread5
List<CustomerVO> resultList = executeQuery("select * from customer",new ArrayList()).subList(begin
beginCount =4800 and endCount = 6000
How can i modify my beginCount and endCount within my for loop?
Any help will be greatly appreciated
Thanks
You've proved multithreading enhances performance have you? If so, how did you benchmark it?
ASKER
>> If so, how did you benchmark it?
benchmarked it using visualvm thread profiler, In our scenario we had 900000 rows of dataprocessing (from database table-select - process - update data) distributed among 6 threads finishes in < 5 minutes.
With a single thread it takes around 30 minutes :)
that was our benchmarking.
benchmarked it using visualvm thread profiler, In our scenario we had 900000 rows of dataprocessing (from database table-select - process - update data) distributed among 6 threads finishes in < 5 minutes.
With a single thread it takes around 30 minutes :)
that was our benchmarking.
That's good - just checking ;) More tomorrow
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
https://www.experts-exchange.com/questions/28196522/String-replace.html
any help will be greatly appreciated
thanks
any help will be greatly appreciated
thanks