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:com.apress.prospringintegration.jmx.JmxNotificationPublisher.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "jmx/notification-publisher.xml");

    try {/*from www .j  av a 2  s  . co  m*/
        Thread.sleep(60000);
    } catch (InterruptedException e) {
        //do nothing
    }

    System.out.println("Sending message");
    MessageChannel send = context.getBean("send", MessageChannel.class);
    send.send(MessageBuilder.withPayload("Sample Message").build());

    try {
        Thread.sleep(180000);
    } catch (InterruptedException e) {
        //do nothing
    }
    context.stop();
}

From source file:foldersync.FolderSync.java

/**
 * @param args the command line arguments
 *//*w w  w .  ja  va  2  s.c  o m*/
public static void main(String[] args) {
    // TODO code application logic here
    //JSONParser parser = new JSONParser();

    try {
        Options options = new Options(args[0]);
        List<HashMap> watchList = options.watchesList();
        while (true) {
            for (HashMap watch : watchList) {
                // System.out.println(watch);
                Sync sync = new Sync((String) watch.get("sourceDir"), (String) watch.get("destDir"),
                        (List) watch.get("watch"), (List) watch.get("dontwatch"));
                sync.syncFolders();
            }
            Thread.sleep(100);
        }
    } catch (IOException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:yangqi.spring3.mbean.SpringMBeanMain.java

/**
 * @param args/*from   w w w .ja  v a2 s  .  c om*/
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException {
    // TODO Auto-generated method stub

    AnnotationTestMBean bean = (AnnotationTestMBean) context.getBean("annotationTestMBean");
    while (true) {
        String name = bean.getName();
        System.out.println(name);
        Thread.sleep(1000);
    }

}

From source file:BoundedChangeListener.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("Stepping Progress");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.VERTICAL);
    aJProgressBar.setStringPainted(true);

    aJProgressBar.addChangeListener(new BoundedChangeListener());

    for (int i = 0; i < 10; i++) {
        aJProgressBar.setValue(i++);//from   w  ww.  ja  va 2 s .c o m
        Thread.sleep(100);
    }

    frame.add(aJProgressBar, BorderLayout.NORTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:demo.vmware.app.Locator.java

/**
 * @param args/*from w  w  w  .  j a va 2s  .  c  o  m*/
 */
public static void main(String[] args) throws Exception {
    String resource[] = { "spring-cache-locator.xml" };
    ClassPathXmlApplicationContext mainContext = new ClassPathXmlApplicationContext(resource, false);
    mainContext.setValidating(true);
    mainContext.refresh();

    Thread.sleep(Long.MAX_VALUE);
}

From source file:demo.vmware.app.DB.java

/**
 * @param args/*w  ww .ja  v  a2  s . c  om*/
 */
public static void main(String[] args) throws Exception {
    String resource = ("spring-db.xml");
    ClassPathXmlApplicationContext mainContext = new ClassPathXmlApplicationContext(new String[] { resource },
            false);
    mainContext.setValidating(true);
    mainContext.refresh();

    Thread.sleep(Long.MAX_VALUE);
}

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

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

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

From source file:Main.java

public static void main(String[] args) throws Exception {
    Main t = new Main();
    t.start();/* w ww.ja  v a 2  s .  com*/
    Thread.sleep(2000);
    t.suspendThread();
    Thread.sleep(2000);
    t.resumeThread();
    Thread.sleep(2000);
    t.stopThread();
}

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

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

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

From source file:com.joshlong.activiti.coordinator.registration1.distribution.consumer.RegistrationConsumerMain.java

public static void main(String[] args) throws Throwable {
    ClassPathXmlApplicationContext cax = new ClassPathXmlApplicationContext("consumer.xml");

    Thread.sleep(1000 * 30);

}