question: public void debug ( String line ) { if ( shuttingDown ) { return ; } synchronized ( cachedDebugMessages ) { if ( g == null ) { cachedDebugMessages . add ( line ) ; } else { if ( ! cachedDebugMessages . isEmpty ( ) ) { g . printDebug ( "[Start of cached messages]" ) ; for ( String cachedLine : cachedDebugMessages ) { g . printDebug ( cachedLine ) ; } g . printDebug ( "[End of cached messages]" ) ; cachedDebugMessages . clear ( ) ; } g . printDebug ( line ) ; } } }
target:  Add a debugmessage to the GUI. If the GUI wasn't created yet, add it to a cache that is send to the GUI once it is created. This is done automatically when a debugmessage is added after the GUI was created.