We do it this way on FrostWire, through this utility function we can check if the runnable / thread used is running from the GUI thread
public static void safeInvokeLater(Runnable runnable) { if (EventQueue.isDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } }
source share