protected class ExecuteTimeoutThread extends Thread { /** Method that is executing. */ protected HttpUriRequest request; /** Timeout in seconds. */ protected int timeout; /** *
Construct a timeout thread with a specific * method instance. * * @param request HTTP request to call abort on. * @param timeout Timeout value to check. */ public ExecuteTimeoutThread( HttpUriRequest request, int timeout ) { super(); this.request = request; this.timeout = timeout; } /** *
Run the thread. Call {@link #interrupt()} when you want this * thread to exit. */ public void run() { try { sleep( timeout * 1000L ); request.abort(); } catch (InterruptedException interruptedException) { } } }