## sdlip.helpers
Class Timer

    java.lang.Object
      |
      +--java.lang.Thread
            |
            +--sdlip.helpers.Timer

All Implemented Interfaces:
  java.lang.Runnable

public class Timer
extends java.lang.Thread

Timer. Usage:

1. "this" which must implement Timeoutable will be called in 3 sec, a separate thread will be created to accomplish this call Timer mytimer = new Timer(3, this, true);
2. Same as above, but no extra thread will be created for the timeout call. Make sure that this call returns quickly.

           Timer mytimer = new Timer(3, this, false);

3. Timer without a Timeoutable: no callback, if mytimer.getTimeout() == 0 it is done.

           Timer mytimer = new Timer(3);

In the second example a single thread serves all Timeoutable's. First example is a bit slower but more robust.

Field Summary
`static int` `REGULAR` User timer.
`static int` `ROBUST` User timer.

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Constructor Summary
`Timer(int reltime)` Creates a timer which has no Timeoutable.
`Timer(int reltime, Timeoutable to, java.lang.Object handle)` Creates a "robust" timer.
`Timer(int reltime, Timeoutable to, java.lang.Object handle, int timerType)` General user timer constructor.

Method Summary
`java.lang.Object` `getHandle()` Delivers the handle that is passed to the Timeoutable
`int` `getTimeout()` Returns remaining time until timeout method is called.
`Timeoutable` `getTimeoutable()` Delivers the Timeoutable under observation
`int` `getType()` Returns REGULAR or ROBUST for a user timer.
`void` `interrupt()` stop the timer
`boolean` `isTimedOut()`
`static void` `main(java.lang.String[] args)`
`void` `run()` The running instance of the Timer.
`void` `setAbsolute(long abstime)` Sets absolute time for timeout
`void` `setTimeout(int reltime)` Sets a new timeout
`java.lang.String` `toString()`

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### REGULAR

    public static final int REGULAR

  User timer. Callback called within the global timer thread

  See Also:
    Constant Field Values

### ROBUST

    public static final int ROBUST

  User timer. Callback called within an extra thread.

  See Also:
    Constant Field Values

Constructor Detail

### Timer

    public Timer(int reltime,
                 Timeoutable to,
                 java.lang.Object handle,
                 int timerType)

  General user timer constructor. timerType is either REGULAR or ROBUST.

### Timer

    public Timer(int reltime,
                 Timeoutable to,
                 java.lang.Object handle)

  Creates a "robust" timer.

### Timer

    public Timer(int reltime)

  Creates a timer which has no Timeoutable.

Method Detail

### getTimeout

    public int getTimeout()

  Returns remaining time until timeout method is called. Zero if timed out.

### isTimedOut

    public boolean isTimedOut()

### setTimeout

    public void setTimeout(int reltime)

  Sets a new timeout

### setAbsolute

    public void setAbsolute(long abstime)

  Sets absolute time for timeout

### getTimeoutable

    public Timeoutable getTimeoutable()

  Delivers the Timeoutable under observation

### getHandle

    public java.lang.Object getHandle()

  Delivers the handle that is passed to the Timeoutable

### getType

    public int getType()

  Returns REGULAR or ROBUST for a user timer.

### interrupt

    public void interrupt()

  stop the timer

  Overrides:
    `interrupt` in class `java.lang.Thread`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Thread`

### run

    public void run()

  The running instance of the Timer. It is used for internal purposes and must not be publicly accessed.

  Specified by:
    `run` in interface `java.lang.Runnable`
  Overrides:
    `run` in class `java.lang.Thread`

### main

    public static void main(java.lang.String[] args)