Java Sleep for Second sleepThreadForOneToSuppliedSecond(Thread t, int seconds)

Here you can find the source of sleepThreadForOneToSuppliedSecond(Thread t, int seconds)

Description

Sleep a thread for a number of seconds.

License

Open Source License

Parameter

Parameter Description
t Thread
seconds int

Exception

Parameter Description
InterruptedException InterruptedException

Declaration

@SuppressWarnings("AccessStaticViaInstance")
public static void sleepThreadForOneToSuppliedSecond(Thread t, int seconds) throws InterruptedException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   www .  jav a 2  s . co m
     * Sleep a thread for a number of seconds.
     *
     * @param t Thread
     * @param seconds int
     * @throws InterruptedException InterruptedException
     */
    @SuppressWarnings("AccessStaticViaInstance")
    public static void sleepThreadForOneToSuppliedSecond(Thread t, int seconds) throws InterruptedException {
        t.sleep(((int) (Math.random() * seconds) + 1) * 1000);
    }
}

Related

  1. sleepForSeconds(long seconds)
  2. sleepSecond(double second)
  3. sleepSeconds(double secs)
  4. sleepSeconds(long seconds)
  5. sleepSeconds(long seconds)
  6. trySleepSeconds(int seconds)
  7. waitForASecond()
  8. waitForSeconds(int timeoutInSeconds)
  9. waitSeconds(final long waitTimeInSeconds)