Guest User

Untitled

a guest
Dec 16th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1.     protected class ExecuteTimeoutThread extends Thread
  2.     {
  3.         /** Method that is executing. */
  4.         protected HttpUriRequest request;
  5.         /** Timeout in seconds. */
  6.         protected int timeout;
  7.  
  8.         /**
  9.          * <p>Construct a timeout thread with a specific
  10.          * method instance.
  11.          *
  12.          * @param   request     HTTP request to call abort on.
  13.          * @param   timeout     Timeout value to check.
  14.          */
  15.         public ExecuteTimeoutThread(
  16.                 HttpUriRequest request,
  17.                 int timeout
  18.                 )
  19.         {
  20.             super();
  21.  
  22.             this.request = request;
  23.             this.timeout = timeout;
  24.         }
  25.  
  26.         /**
  27.          * <p>Run the thread. Call {@link #interrupt()} when you want this
  28.          * thread to exit.
  29.          */
  30.         public void run()
  31.         {
  32.             try
  33.             {
  34.                 sleep( timeout * 1000L );
  35.                 request.abort();
  36.             }
  37.             catch (InterruptedException interruptedException)
  38.             {
  39.             }
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment