Inefficient shutdown() from Executors , preventing the completion of process
Hi All,
I am using newFixedThreadPool() from Executors class. when i am fixing the thread size to 2, last two threads are not completing their process,they just stay hanged...I get doubt in my usage of Executors. Could any one please verify the usage....Should any condition to be given before invoking shutdown()....
Code :
java.util.concurrent.ExecutorService es=Executors.newFixedThreadPool(2);
for(int i=0;i<siteArray.size();i+=2)
{
String site_ID=siteArray.get(i).toString();
String url=siteArray.get(i+1).toString();//just an array of sites
es.execute(new WebCrawlerBatch(url,Integer.parseInt(site_ID)));//process of each thread
}
es.shutdown();
siteArray=null;
Re: Inefficient shutdown() from Executors , preventing the completion of process
Please define 'not completing their process'. How large is siteArray? Do the first few Runnables added to the execute function exit properly? (Calling shutdown doesn't stop the threads, as the API states: " Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.")