Sleep utilities : Utilities « Threads « Java






Sleep utilities

  



public final class TimerUtil
{
  public final static void wait(int waitTime)
  {
    try {
      Thread.sleep(waitTime);
    }
    catch (Exception e) {}
  }

  public final static void waitRandom(int time)
  {
    int waitTime = (int)(Math.random() * (double)time);   
    try {
      Thread.sleep(waitTime);
    }
    catch (Exception e) {}
  }
}

   
    
  








Related examples in the same category

1.View current Threads in a table View current Threads in a table
2.Exception call backException call back
3.Listing all threads and threadgroups in the VM.Listing all threads and threadgroups in the VM.
4.Early returnEarly return
5.Transition DetectorTransition Detector
6.Busy Flag
7.Thread-based logging utility
8.Return a new instance of the given class. Checks the ThreadContext classloader first, then uses the System classloader.
9.Finds a resource with the given name.