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);
    }
  }
}

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 ) ; } } }
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 .
