org.jtoolkit.essence.concurrency
Class Timeout

java.lang.Object
  extended by org.jtoolkit.essence.concurrency.Timeout

public class Timeout
extends java.lang.Object

A standardised timeout with a fixed end time. Using the same timeout ensures all operation stop at a given future time.

Author:
Peter Lawrey

Nested Class Summary
static class Timeout.TimeoutException
           
 
Field Summary
static Timeout ALWAYS
           
static Timeout NEVER
           
static java.lang.String NEVER_STR
           
 
Constructor Summary
Timeout(long timeoutMS)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 long getMillisLeft()
           
 int hashCode()
           
 boolean hasNotTimedOut()
           
 boolean isNever()
           
 void join(java.lang.Thread thread)
           
 Timeout or(Timeout timeout)
           
static Timeout parse(java.lang.String serverTimeOutStr)
          Derive a timeout fronm a string.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NEVER

public static final Timeout NEVER

ALWAYS

public static final Timeout ALWAYS

NEVER_STR

public static final java.lang.String NEVER_STR
See Also:
Constant Field Values
Constructor Detail

Timeout

public Timeout(long timeoutMS)
Method Detail

parse

public static Timeout parse(java.lang.String serverTimeOutStr)
                     throws java.lang.IllegalArgumentException
Derive a timeout fronm a string. Either the time is "never" or "" which means never or a delay in milliseconds.

Throws:
java.lang.IllegalArgumentException

isNever

public boolean isNever()

hasNotTimedOut

public boolean hasNotTimedOut()

getMillisLeft

public long getMillisLeft()

join

public void join(@NotNull
                 java.lang.Thread thread)
          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

or

public Timeout or(Timeout timeout)


Copyright © Peter Lawrey. All Rights Reserved.