List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void WakeUpPritner() { byte[] b = { '\0', '\0', '\0' }; printMessage(b, 3);//from w ww . j a v a 2s. c om try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } byte[] b1 = { 27, 64 }; printMessage(b1, 2); }
From source file:Main.java
public static Runnable createNewThread(final String name) { return new Runnable() { @Override/*from w w w . j a v a2s . com*/ public void run() { try { System.out.println("before: " + name); TimeUnit.SECONDS.sleep(3); System.out.println("end: " + name); } catch (InterruptedException e) { e.printStackTrace(); } } }; }
From source file:Main.java
public static void invokeAndWait(final Runnable doRun) { if (doRun == null) { throw new IllegalArgumentException("The runnable cannot be null"); }//w w w . java 2 s. com if (EventQueue.isDispatchThread()) { doRun.run(); } else { try { EventQueue.invokeAndWait(doRun); } catch (InterruptedException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } }
From source file:Main.java
private static void sleep(int millis) { try {/*from ww w. j a va 2 s . c o m*/ Thread.sleep(millis); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Main.java
private static boolean waitForProcess(Process p) { boolean isSuccess = false; int returnCode; try {/*from ww w. j ava2 s. c om*/ returnCode = p.waitFor(); switch (returnCode) { case 0: isSuccess = true; break; case 1: break; default: break; } } catch (InterruptedException e) { e.printStackTrace(); } return isSuccess; }
From source file:Main.java
/** * // w w w .j ava 2 s. co m * @param ms */ public static void Sleep(int ms) { try { Thread.sleep(ms); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Main.java
/** * Waits for all the given threads to complete before returning. * * @param $threads//from w ww. j a v a 2 s .co m */ public static void joinAll(Thread... $threads) { for (int $i = 0; $i < $threads.length; $i++) try { $threads[$i].join(); } catch (InterruptedException $e) { $e.printStackTrace(); } }
From source file:Main.java
public static void executeRunnable(Runnable runnable, boolean waits) { if (SwingUtilities.isEventDispatchThread()) { runnable.run();// w ww .j a va 2s . c o m } else { try { if (waits) { SwingUtilities.invokeAndWait(runnable); } else { SwingUtilities.invokeLater(runnable); } } catch (InterruptedException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } }
From source file:Main.java
/** * this function work by permission.// www. ja v a2s .co m */ public static void pressHome() { new Thread(new Runnable() { @Override public void run() { Instrumentation m_Instrumentation = new Instrumentation(); m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } m_Instrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); } }).start(); }
From source file:Main.java
/** * For testing only - prevent the tests to exit until all thread finished *//* w w w. j a v a 2 s . co m*/ public static void waitForBackgroundThreads() { Enumeration e = threads.elements(); while (e.hasMoreElements()) { Thread thread = (Thread) e.nextElement(); if (thread.isAlive()) { try { thread.join(); } catch (InterruptedException ignore) { ignore.printStackTrace(); } } } }