Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Inefficient shutdown() from Executors , preventing the completion of process

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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()....


    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;


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default 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.")

Similar Threads

  1. remote system shutdown
    By prince joseph in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 28th, 2010, 02:35 AM
  2. Kill a process
    By subhvi in forum Java Theory & Questions
    Replies: 5
    Last Post: January 14th, 2010, 09:11 PM
  3. process control
    By ttsdinesh in forum Java Native Interface
    Replies: 6
    Last Post: October 27th, 2009, 06:29 PM
  4. Patch Process
    By Drakenmul in forum Java Theory & Questions
    Replies: 3
    Last Post: August 2nd, 2009, 03:09 AM
  5. Detecting File Download Completion
    By fedfan in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: June 5th, 2009, 04:27 AM