Results 1 to 2 of 2
  1. #1
    bourn2lead is offline Member
    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    Default set timeout for completion of each thread

    Hi, I have a requirement where I need to start n threads and set timeout for completion of each thread.
    if the thread is not executed successfully(because of timeout ) i have to enter in audit table that it failed because of timeout
    if executed successfully update audit table with success.

    can some one give me solution for this using ThreadPoolExecutor available jdk1.5

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    Keep track of all the threads in an ArrayList, and create a Long[] corresponding to each thread with System.currentMillis() + timeoutMillis. Create a loop with a sleep. Each time around the loop, see if each thread ended by itself or if it needs stopped.

Similar Threads

  1. Implement a timeout
    By pjmorce in forum Advanced Java
    Replies: 5
    Last Post: 04-27-2010, 02:36 AM
  2. IDE with auto completion?
    By iceflyin in forum New To Java
    Replies: 8
    Last Post: 04-21-2008, 01:07 PM
  3. Replies: 9
    Last Post: 12-18-2007, 09:02 AM
  4. auto completion window does not pop-up
    By erdaffi in forum NetBeans
    Replies: 0
    Last Post: 12-11-2007, 12:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •