Example usage for java.lang InterruptedException printStackTrace

List of usage examples for java.lang InterruptedException printStackTrace

Introduction

In this page you can find the example usage for java.lang InterruptedException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static void main(String[] args) {
    Thread t = new Thread(Main::run);
    t.start();/*from w  ww  . ja  va  2 s . c  o  m*/
    try {
        Thread.currentThread().sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    t.interrupt();
}

From source file:Main.java

public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        System.out.println("i = " + i);

        try {/*from   w  w w . j  a v  a2s.  c  om*/
            Thread.sleep(1000);

        } catch (InterruptedException ie) {
            ie.printStackTrace();
        }
    }
}

From source file:Main.java

public static void main(String[] args) {
    Thread t1 = new Thread(Main::print);
    t1.start();//from   ww  w.j a  v a  2s . c o m
    try {
        t1.join();
        // "main" thread waits until t1 is terminated
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("Done.");
}

From source file:SimpleSplashScreen.java

public static void main(String[] arg) {
    JWindow jwin = new JWindow();
    jwin.getContentPane().add(new JLabel("Loading ZIP/JAR Manager...", SwingConstants.CENTER));
    jwin.setBounds(200, 200, 200, 100);/*from  w w w  .ja  va2 s .  co m*/
    jwin.setVisible(true);

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    jwin.setVisible(false);
    jwin.dispose();

}

From source file:Main.java

public static void main(String args[]) {
    executor = Executors.newScheduledThreadPool(1);
    runnable = new Runnable() {
        @Override//from   w  w w. ja  va 2  s.  c om
        public void run() {
            System.out.println("Inside runnable" + i++);
        }
    };
    future = executor.scheduleWithFixedDelay(runnable, 0, 2, TimeUnit.SECONDS);
    try {
        Thread.sleep(4000); // sleeping for 2 seconds
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    future.cancel(false);
    future = executor.scheduleWithFixedDelay(runnable, 0, 10, TimeUnit.SECONDS);
}

From source file:Test.java

public static void main(String[] args) {
    final Lock firstLock = new ReentrantLock();
    final Lock secondLock = new ReentrantLock();
    firstLock.lock();/* ww  w.  j a  v a 2 s . c o m*/
    Thread secondThread = new Thread(new Runnable() {
        public void run() {
            secondLock.lock();
            firstLock.lock();
        }
    });
    secondThread.start();
    try {
        Thread.sleep(250);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    secondLock.lock();

    secondLock.unlock();
    firstLock.unlock();
}

From source file:com.bt.aloha.batchtest.JmxScenarioRunner.java

public static void main(String[] args) {
    while (true)/*  w ww.j ava  2  s. co m*/
        try {
            log.info("Sleeping...");
            Thread.sleep(60000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
}

From source file:com.jbrisbin.vpc.jobsched.JobScheduler.java

public static void main(String[] args) {
    ApplicationContext appCtx = new ClassPathXmlApplicationContext("/jobsched.xml");
    while (true) {
        try {//from   ww w. j  a  va2s.c o m
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

From source file:TryThread.java

public static void main(String[] args) {
    Thread first = new TryThread("A ", "a ", 200L);
    Thread second = new TryThread("B ", "b ", 300L);
    Thread third = new TryThread("C ", "c ", 500L);
    first.start();/*from  w ww .java 2  s. c  om*/
    second.start();
    third.start();
    try {
        first.join(2000); // Wait up to 2 second for thread1 to die
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    CountDownLatch latch = new CountDownLatch(1);
    for (int threadNo = 0; threadNo < 1000; threadNo++) {
        Runnable t = new Test(latch);
        new Thread(t).start();
    }/*  w  w  w.j  ava 2 s.  co m*/
    try {
        latch.await();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("done");
}