org.apache.commons.httpclient.util

Class TimeoutController

public final class TimeoutController extends Object

Executes a task with a specified timeout.

Since: 2.0

Version: $Revision: 291181 $

Author: Ortwin Glueck Mike Bowler

Nested Class Summary
static classTimeoutController.TimeoutException
Signals that the task timed out.
Method Summary
static voidexecute(Thread task, long timeout)
Executes task.
static voidexecute(Runnable task, long timeout)
Executes task in a new deamon Thread and waits for the timeout.

Method Detail

execute

public static void execute(Thread task, long timeout)
Executes task. Waits for timeout milliseconds for the task to end and returns. If the task does not return in time, the thread is interrupted and an Exception is thrown. The caller should override the Thread.interrupt() method to something that quickly makes the thread die or use Thread.isInterrupted().

Parameters: task The thread to execute timeout The timeout in milliseconds. 0 means to wait forever.

Throws: TimeoutException if the timeout passes and the thread does not return.

execute

public static void execute(Runnable task, long timeout)
Executes task in a new deamon Thread and waits for the timeout.

Parameters: task The task to execute timeout The timeout in milliseconds. 0 means to wait forever.

Throws: TimeoutException if the timeout passes and the thread does not return.

Copyright (c) 1999-2005 - Apache Software Foundation