1 22 23 package salsa.util; 24 25 import javax.swing.*; 26 27 public class ThreadUtils 28 { 29 public static void ensureGuiThread() 30 { 31 33 if( SwingUtilities.isEventDispatchThread() ) 34 return; 35 36 throw new RuntimeException ( "only the gui thread should invoke this method" ); 37 } 38 39 public static void ensureWorkerThread() 40 { 41 if( !SwingUtilities.isEventDispatchThread() ) 42 return; 43 44 throw new RuntimeException ( "only worker threads should invoke this method" ); 45 } 46 47 } 48 | Popular Tags |