Example usage for java.lang Thread sleep

List of usage examples for java.lang Thread sleep

Introduction

In this page you can find the example usage for java.lang Thread sleep.

Prototype

public static native void sleep(long millis) throws InterruptedException;

Source Link

Document

Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers.

Usage

From source file:Main.java

public static void main(String[] args) {
    new Thread(uncheck(() -> {
        Thread.sleep(1000L);
        System.out.println("done");
    })).start();/* w w  w  .  j a v  a2 s. co  m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long numMillisecondsToSleep = 5000;
    Thread.sleep(numMillisecondsToSleep);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long numMillisecondsToSleep = 5000; // 5 seconds
    Thread.sleep(numMillisecondsToSleep);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    long elapsedTimeMillis = System.currentTimeMillis() - start;
    System.out.println(elapsedTimeMillis);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    // //  ww  w.j  a va  2  s.c o  m
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    System.out.println(elapsedTimeMillis);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;

    float elapsedTimeDay = elapsedTimeMillis / (24 * 60 * 60 * 1000F);
    System.out.println(elapsedTimeDay);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    // Get elapsed time in hours
    float elapsedTimeHour = elapsedTimeMillis / (60 * 60 * 1000F);
    System.out.println(elapsedTimeHour);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;

    float elapsedTimeSec = elapsedTimeMillis / 1000F;
    System.out.println(elapsedTimeSec);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    // /*w  w  w  . ja v a2 s  .co m*/
    float elapsedTimeSec = elapsedTimeMillis / 1000F;
    System.out.println(elapsedTimeSec);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    // Get elapsed time in minutes
    float elapsedTimeMin = elapsedTimeMillis / (60 * 1000F);
    System.out.println(elapsedTimeMin);
}