com.waveset.util
Class SafeSleep

java.lang.Object
  extended bycom.waveset.util.SafeSleep

public class SafeSleep
extends java.lang.Object

Initially copied from com.waveset.adapter.util, but then modified it to be more robust to changes in the system clock.


Constructor Summary
SafeSleep()
           
 
Method Summary
static void sleep(long millis)
          Sleep for a total of millis milliseconds.
static void sleepUntil(java.util.Date endDate)
          Sleep until the endDate.
static boolean sleepUntilInterrupted(long millis)
          Same as sleep except InterruptedException is not thrown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SafeSleep

public SafeSleep()
Method Detail

sleep

public static void sleep(long millis)
                  throws java.lang.InterruptedException
Sleep for a total of millis milliseconds. To minimize the drifting inaccuracies of the Thread.sleep() method, we will perform occassional checks with the system clock. This is only really useful for millis > 60000, otherwise you should just use Thread.sleep().

Parameters:
millis - milliseconds to sleep
Throws:
java.lang.InterruptedException

sleepUntilInterrupted

public static boolean sleepUntilInterrupted(long millis)
Same as sleep except InterruptedException is not thrown.

Returns:
true iff the sleep was interrupted

sleepUntil

public static void sleepUntil(java.util.Date endDate)
                       throws java.lang.InterruptedException
Sleep until the endDate. To minimize the drifting inaccuracies of the Thread.sleep() method, we will perform occassional checks with the system clock.

Parameters:
endDate - Date to return execution from the method
Throws:
java.lang.InterruptedException