protected void loop(){
  try {
synchronized (this) {
      if (!stopRequest) {
        if (delay > 0) {
          Date before, after;
          if (Cfg.DEBUG) {
            before=new Date();
          }
          wait(delay);
          if (Cfg.DEBUG) {
            after=new Date();
            final long elapsed=after.getTime() - before.getTime();
            if (elapsed > delay * 1.5) {
              Check.log(TAG + " (loop) Error: delay=" + delay+ " elapsed="+ elapsed+ "s");
            }
          }
        }
      }
    }
    while (true) {
      if (stopRequest) {
        break;
      }
      if (!isSuspended()) {
        actualGo();
      }
      Date before, after;
      if (Cfg.DEBUG) {
        before=new Date();
      }
synchronized (this) {
        if (stopRequest) {
          break;
        }
        wait(period);
      }
      if (Cfg.DEBUG) {
        after=new Date();
        final long elapsed=after.getTime() - before.getTime();
        if (elapsed > period * 1.5) {
          Check.log(TAG + " (loop) Error: period=" + period+ " elapsed="+ elapsed+ "s "+ this);
        }
      }
    }
  }
 catch (  final Exception ex) {
    if (Cfg.EXCEPTION) {
      Check.log(ex);
    }
    if (Cfg.DEBUG) {
      Check.log(ex);
      Check.log(TAG + " Error: " + ex.toString());
    }
  }
  stopRequest=false;
}

protected void loop ( ) { try { synchronized ( this ) { if ( ! stopRequest ) { if ( delay > 0 ) { Date before , after ; if ( Cfg . DEBUG ) { before = new Date ( ) ; } wait ( delay ) ; if ( Cfg . DEBUG ) { after = new Date ( ) ; final long elapsed = after . getTime ( ) - before . getTime ( ) ; if ( elapsed > delay * 1.5 ) { Check . log ( TAG + " (loop) Error: delay=" + delay + " elapsed=" + elapsed + "s" ) ; } } } } } while ( true ) { if ( stopRequest ) { break ; } if ( ! isSuspended ( ) ) { actualGo ( ) ; } Date before , after ; if ( Cfg . DEBUG ) { before = new Date ( ) ; } synchronized ( this ) { if ( stopRequest ) { break ; } wait ( period ) ; } if ( Cfg . DEBUG ) { after = new Date ( ) ; final long elapsed = after . getTime ( ) - before . getTime ( ) ; if ( elapsed > period * 1.5 ) { Check . log ( TAG + " (loop) Error: period=" + period + " elapsed=" + elapsed + "s " + this ) ; } } } } catch ( final Exception ex ) { if ( Cfg . EXCEPTION ) { Check . log ( ex ) ; } if ( Cfg . DEBUG ) { Check . log ( ex ) ; Check . log ( TAG + " Error: " + ex . toString ( ) ) ; } } stopRequest = false ; }
loop . i synchronized qui dentro forse non servono , perche ' questo metodo e ' chiamato solo da run , che e ' gia ' sincronizzato
