List of usage examples for java.lang Runnable run
public abstract void run();
Runnable
is used to create a thread, starting the thread causes the object's run
method to be called in that separately executing thread. From source file:Main.java
public static Thread runOnBackgroundThread(final Runnable runnable) { final Thread t = new Thread() { @Override/*from w w w. jav a 2 s . c o m*/ public void run() { runnable.run(); } }; t.start(); return t; }
From source file:Main.java
public static void Run(Runnable r) { new AsyncTask<Void, Void, Void>() { @Override//from w ww.j a va2 s . c o m protected Void doInBackground(Void... params) { r.run(); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:Main.java
public static Runnable excAsync(final Runnable runnable, boolean isDeamon) { Thread thread = new Thread() { @Override/*from w ww.ja va2s .c o m*/ public void run() { runnable.run(); } }; thread.setDaemon(isDeamon); thread.start(); return runnable; }
From source file:it.serverSystem.RestartTest.java
private static void verifyFailWith403(Runnable runnable) { try {/*from www .jav a 2s . c om*/ runnable.run(); fail(); } catch (Exception e) { assertThat(e.getMessage()).contains("403"); } }
From source file:Main.java
public static void runTimer(int duration, final Runnable run) { Timer t = new Timer(duration, new ActionListener() { public void actionPerformed(ActionEvent e) { run.run(); }//from ww w .j a v a2s. co m }); t.setRepeats(false); t.start(); }
From source file:Main.java
public static void fore(final Runnable r) { main.post(new Runnable() { @Override// ww w . j a v a 2 s. c o m public void run() { try { r.run(); } catch (Throwable e) { e.printStackTrace(); } } }); }
From source file:Main.java
public static void backQueue(final Runnable r) { back.post(new Runnable() { @Override// ww w .ja va2 s . c o m public void run() { try { r.run(); } catch (Throwable e) { e.printStackTrace(); } } }); }
From source file:com.splunk.shuttl.testutil.TUtilsMBean.java
/** * Runs a runnable while MBeans in {@link TUtilsMBean#registerMBeans()} are * registered. The method makes sure that the MBeans are unregistered when the * runnable has finished running.//from ww w.jav a2 s. co m * * @param path * to the directory where configured Shuttl confs live. */ public static void runWithRegisteredMBeans(File confDir, Runnable runnable) { try { registerMBeans(confDir); runnable.run(); } finally { unregisterMBeans(); } }
From source file:Main.java
/** * Runs the given Runnable inside the Swing event dispatch thread and blocks * until the runnable has completed. If the current thread is the Swing EDT * then it just runs it, otherwise it calls SwingUtilities.invokeLater() * //from ww w . j a v a 2 s . co m * @param runnable * @throws InvocationTargetException * @throws InterruptedException */ public static void runNowInEventThread(Runnable runnable) throws InterruptedException, InvocationTargetException { if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeAndWait(runnable); } }
From source file:Main.java
public static void run(final Runnable run) { new AsyncTask<Void, Void, Void>() { @Override//from ww w . j a v a 2 s . com protected Void doInBackground(Void... params) { run.run(); return null; } }; }