BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(100, true);
RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy();
ExecutorService executor = new ThreadPoolExecutor(4, 10, 0L, TimeUnit.MILLISECONDS, queue,handler);
executor.execute(new Runnable() {
@Override
public void run() {
for(looping arraylist){
operations related to calling proc...
}
}
});
executor.shutdown();
while (executor.isTerminated() == false){
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
The performance of the above code is way too slow, it takes 7minutes to complete the entire operation and get the data.
I am trying get large data from 2 stored procedures. To increase the speed I am using multithreading.
Can someone please provide solution to increase the performance to large extent.