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:MyThread.java

public static void main(String[] args) throws Exception {
    PipedWriter pw = new PipedWriter();
    PipedReader pr = new PipedReader(pw);

    MyThread mt1 = new MyThread("src", pr, pw);
    MyThread mt2 = new MyThread("dst", pr, pw);

    mt1.start();/*from  w w w .ja  va2  s.co  m*/

    Thread.sleep(2000);
    mt2.start();
}

From source file:com.everis.storage.Application.java

public static void main(String[] args) throws Exception {
    System.out.println("ENV:" + System.getenv());
    Thread.sleep(5000);
    ApplicationContext ctx = SpringApplication.run(Application.class, args);
    /*//from   w ww .  ja v a2  s . com
    for(String bean : ctx.getBeanDefinitionNames()) {
    System.out.println("Bean:" + bean);
    }*/
}

From source file:org.apache.cxf.transport.xmpp.pubsub.Server.java

public static void main(String[] args) throws Exception {
    new ClassPathXmlApplicationContext("server-pubsub-applicationContext.xml");
    Thread.sleep(30 * 60 * 1000);
}

From source file:Wake.java

public static void main(String args[]) {
    Wake queue = new Wake();
    Runnable r = new RunThis(queue);
    Thread t;/* w  w  w  .  ja  v  a  2 s  . c  om*/
    for (int i = 0; i < 10; i++) {
        t = new Thread(r);
        t.start();
    }

    for (int i = 0; i < 11; i++) {
        try {
            Thread.sleep((long) (Math.random() * 1000));
        } catch (InterruptedException e) {
        }
        System.out.println("About to wake one thread");
        queue.wakeOne();
    }
}

From source file:PiInterrupt.java

public static void main(String[] args) {
    PiInterrupt pi = new PiInterrupt();
    Thread t = new Thread(pi);
    t.start();/*from  ww  w  .  jav  a 2s. com*/

    try {
        Thread.sleep(10000);
        t.interrupt();
    } catch (InterruptedException x) {
    }
}

From source file:Daemon.java

public static void main(String[] args) throws Exception {
    Thread d = new Daemon();
    System.out.println("d.isDaemon() = " + d.isDaemon());
    // Allow the daemon threads to
    // finish their startup processes:
    Thread.sleep(1000);
}

From source file:com.apress.prospringintegration.social.twitter.TwitterInbound.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/twitter/twitter-inbound.xml");

    Thread.sleep(10 * 60 * 1000);
}

From source file:MainClass.java

public static void main(String[] args) {
    MainClass ad11 = new MainClass();

    try {//from ww  w . j a v a 2  s  .c om
        Thread.sleep(5000);
    } catch (InterruptedException e) {
    }

    ad11.dumpConnectedInfo(ad11.getAccessibleContext());
}

From source file:OnlyOneInMethod.java

public static void main(String[] args) {
    final OnlyOneInMethod ooim = new OnlyOneInMethod("obj1");

    Runnable runA = new Runnable() {
        public void run() {
            ooim.doStuff(3);/*from ww w  .  ja  va 2s .c  o m*/
        }
    };

    Thread threadA = new Thread(runA, "threadA");
    threadA.start();

    try {
        Thread.sleep(200);
    } catch (InterruptedException x) {
    }

    Runnable runB = new Runnable() {
        public void run() {
            ooim.doStuff(7);
        }
    };

    Thread threadB = new Thread(runB, "threadB");
    threadB.start();
}

From source file:com.apress.prospringintegration.social.twitter.TwitterDmInbound.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("/spring/twitter/twitter-dm-inbound.xml");

    Thread.sleep(10 * 60 * 1000);
}