Example usage for java.lang Runnable run

List of usage examples for java.lang Runnable run

Introduction

In this page you can find the example usage for java.lang Runnable run.

Prototype

public abstract void run();

Source Link

Document

When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

Usage

From source file:Main.java

public static void runInMainThread(Runnable runnable) {
    if (isInMainThread()) {
        runnable.run();
    } else {//from w ww  . j  ava2s .  com
        post(runnable);
    }
}

From source file:Main.java

/**
 * Execute the specified runnable in the EDT.
 *
 * @param runnable The runnable to run in EDT.
 *///from   w  w  w.  ja v  a 2  s .  c o m
public static void inEdt(Runnable runnable) {
    if (isEDT()) {
        runnable.run();
    } else {
        EventQueue.invokeLater(runnable);
    }
}

From source file:Main.java

public static void invokeLater(Runnable runnable) {
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();
    } else {/* ww  w  .java2 s .c  o m*/
        SwingUtilities.invokeLater(runnable);
    }
}

From source file:Main.java

public static void invokeInEDT(Runnable runnable) {
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();
    } else {/*  w  w w  .  j a  v a2  s . co m*/
        SwingUtilities.invokeLater(runnable);
    }
}

From source file:Main.java

public static void invokeAndWait(Runnable r) {
    if (SwingUtilities.isEventDispatchThread()) {
        r.run();
        return;//from  w  ww  .ja v  a  2 s.co  m
    }
    try {
        SwingUtilities.invokeAndWait(r);
    } catch (Exception e) {
        throw new IllegalStateException("Unable to invoke/wait for task", e);
    }
}

From source file:Main.java

public static final void invoke(Runnable r) {
    if (SwingUtilities.isEventDispatchThread())
        r.run();
    else//from   w  w w .ja  v  a2  s  .c o m
        SwingUtilities.invokeLater(r);
}

From source file:Main.java

public static void invokeAndWait(Runnable task) {
    if (SwingUtilities.isEventDispatchThread()) {
        task.run();
    } else {//from w  w w. j  a v  a2s  .co  m
        try {
            SwingUtilities.invokeAndWait(task);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:Main.java

public static void invokeAndContiune(Runnable runnable) {
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();
    } else {//from ww w  . jav a  2 s .com
        SwingUtilities.invokeLater(runnable);
    }

}

From source file:Main.java

/**
 * Invoke a runnable object on the AWT event thread. Does not wait
 * necessarily for it to finish. If the current thread is already the event
 * queue, the {@link Runnable} object is simply executed.
 * /*w  w  w.  j  a v  a 2s  .  c  om*/
 * @param runnable
 *            Runnable capturing code to execute on the awt thread.
 */
public static void invokeOnEventQueue(Runnable runnable) {
    if (EventQueue.isDispatchThread()) {
        runnable.run();
    } else {
        SwingUtilities.invokeLater(runnable);
    }
}

From source file:Main.java

static void invokeAndWait(Runnable task) {
    if (SwingUtilities.isEventDispatchThread()) {
        task.run();
    } else {/*from   w ww. jav a  2 s  . co  m*/
        try {
            SwingUtilities.invokeAndWait(task);
        } catch (Exception ex) {
            ex.printStackTrace();
            ex.getLocalizedMessage();
        }
    }
}