/[classpath]/classpath/java/lang/Thread.java
ViewVC logotype

Diff of /classpath/java/lang/Thread.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by jfrijters, Mon Dec 6 20:43:13 2004 UTC revision 1.11 by mark, Thu Dec 30 13:18:18 2004 UTC
# Line 769  public class Thread implements Runnable Line 769  public class Thread implements Runnable
769     * are no guarantees which thread will be next to run, but most VMs will     * are no guarantees which thread will be next to run, but most VMs will
770     * choose the highest priority thread that has been waiting longest.     * choose the highest priority thread that has been waiting longest.
771     *     *
772     * @param ms the number of milliseconds to sleep, or 0 for forever     * @param ms the number of milliseconds to sleep.
773     * @throws InterruptedException if the Thread is interrupted; it's     * @throws InterruptedException if the Thread is (or was) interrupted;
774     *         <i>interrupted status</i> will be cleared     *         it's <i>interrupted status</i> will be cleared
775     * @see #notify()     * @throws IllegalArgumentException if ms is negative
776     * @see #wait(long)     * @see #interrupt()
777     */     */
778    public static void sleep(long ms) throws InterruptedException    public static void sleep(long ms) throws InterruptedException
779    {    {
# Line 785  public class Thread implements Runnable Line 785  public class Thread implements Runnable
785     * time. The Thread will not lose any locks it has during this time. There     * time. The Thread will not lose any locks it has during this time. There
786     * are no guarantees which thread will be next to run, but most VMs will     * are no guarantees which thread will be next to run, but most VMs will
787     * choose the highest priority thread that has been waiting longest.     * choose the highest priority thread that has been waiting longest.
788       * <p>
789       * Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs
790       * do not offer that fine a grain of timing resolution. When ms is
791       * zero and ns is non-zero the Thread will sleep for at least one
792       * milli second. There is no guarantee that this thread can start up
793       * immediately when time expires, because some other thread may be
794       * active.  So don't expect real-time performance.
795     *     *
796     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do     * @param ms the number of milliseconds to sleep
    * not offer that fine a grain of timing resolution. Besides, there is  
    * no guarantee that this thread can start up immediately when time expires,  
    * because some other thread may be active.  So don't expect real-time  
    * performance.  
    *  
    * @param ms the number of milliseconds to sleep, or 0 for forever  
797     * @param ns the number of extra nanoseconds to sleep (0-999999)     * @param ns the number of extra nanoseconds to sleep (0-999999)
798     * @throws InterruptedException if the Thread is interrupted; it's     * @throws InterruptedException if the Thread is (or was) interrupted;
799     *         <i>interrupted status</i> will be cleared     *         it's <i>interrupted status</i> will be cleared
800     * @throws IllegalArgumentException if ns is invalid     * @throws IllegalArgumentException if ms or ns is negative
801     * @see #notify()     *         or ns is larger than 999999.
802     * @see #wait(long, int)     * @see #interrupt()
803     */     */
804    public static void sleep(long ms, int ns) throws InterruptedException    public static void sleep(long ms, int ns) throws InterruptedException
805    {    {
806      if(ms < 0 || ns < 0 || ns > 999999)      if (ms < 0 || ns < 0 || ns > 999999)
807          throw new IllegalArgumentException();        throw new IllegalArgumentException();
808    
809        if (ns > 0 && ms == 0)
810          {
811            ms = 1;
812            ns = 0;
813          }
814    
815      VMThread.sleep(ms, ns);      if (ms > 0)
816          VMThread.sleep(ms, ns);
817        else if (interrupted())
818          throw new InterruptedException();
819    }    }
820    
821    /**    /**

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26