Here you can find the source of invoke(Runnable runnable)
public static void invoke(Runnable runnable)
//package com.java2s; //License from project: Apache License import javax.swing.SwingUtilities; public class Main { public static void invoke(Runnable runnable) { dispatch(runnable);/* ww w . java 2 s. c o m*/ } public static void dispatch(Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } } }