How do I pause the current thread?

You can pause a current thread for a number of milliseconds by using the sleep() method of the Thread class. While the current thread is sleeping, it will allow other threads to execute.

package org.kodejava.lang;

public class ThreadSleepDemo implements Runnable {
    public static void main(String[] args) {
        Thread thread = new Thread(new ThreadSleepDemo());

    // The run() method will be invoked when the thread is started.
    public void run() {
        try {
            // Wait for 10 seconds
        } catch (InterruptedException e) {

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.