TimeoutException.java

  1. /*
  2.   File: TimeoutException.java

  3.   Originally written by Doug Lea and released into the public domain.
  4.   This may be used for any purposes whatsoever without acknowledgment.
  5.   Thanks for the assistance and support of Sun Microsystems Labs,
  6.   and everyone contributing, testing, and using this code.

  7.   History:
  8.   Date       Who                What
  9.   29Jun1998  dl               Create public version
  10.    4Aug1998  dl               Change to extend InterruptedException
  11. */

  12. package org.dbunit.util.concurrent;

  13. /**
  14.  * Thrown by synchronization classes that report
  15.  * timeouts via exceptions. The exception is treated
  16.  * as a form (subclass) of InterruptedException. This both
  17.  * simplifies handling, and conceptually reflects the fact that
  18.  * timed-out operations are artificially interrupted by timers.
  19.  *
  20.  * @author Doug Lea
  21.  * @author Last changed by: $Author$
  22.  * @version $Revision$ $Date$
  23.  * @since ? (pre 2.1)
  24.  */
  25. public class TimeoutException extends InterruptedException {

  26.   /**
  27.    * The approximate time that the operation lasted before
  28.    * this timeout exception was thrown.
  29.    **/

  30.   public final long duration;
  31.   /**
  32.    * Constructs a TimeoutException with given duration value.
  33.    **/
  34.   public TimeoutException(long time) {
  35.     duration = time;
  36.   }

  37.   /**
  38.      * Constructs a TimeoutException with the
  39.      * specified duration value and detail message.
  40.      */
  41.   public TimeoutException(long time, String message) {
  42.     super(message);
  43.     duration = time;
  44.   }
  45. }