Here you can find the source of callOnGUIThread(Runnable runnable)
public static void callOnGUIThread(Runnable runnable)
//package com.java2s; //License from project: Apache License import com.google.common.base.Preconditions; import javax.swing.SwingUtilities; public class Main { public static void callOnGUIThread(Runnable runnable) { Preconditions.checkNotNull(runnable); if (SwingUtilities.isEventDispatchThread()) { runnable.run();//w w w . ja v a 2s .c o m } else { SwingUtilities.invokeLater(runnable::run); } } }