Program: 19998
Project: 19998
Buggy source:
/** 
 * Suoritt�� s�ikeen.
 */
@Override public void run(){
  gameMode=new SurvivalMode(dm,context,gameActivity);
  hud=new Hud(context);
  touchManager=new TouchManager(dm,surface,context,hud);
  waveStartTime=android.os.SystemClock.uptimeMillis();
  lastMovementUpdate=waveStartTime;
  lastAiUpdateStateOne=waveStartTime;
  lastAiUpdateStateTwo=waveStartTime;
  lastAiUpdateStateThree=waveStartTime;
  lastAiUpdateStateFour=waveStartTime;
  lastCooldownUpdate=waveStartTime;
  lastGameModeUpdate=waveStartTime;
  while (running) {
    long currentTime=android.os.SystemClock.uptimeMillis();
    if (currentTime - lastMovementUpdate >= 20) {
      lastMovementUpdate=currentTime;
      for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
        if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.enemyStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.enemies.get(i).updateMovement(currentTime);
        }
      }
      for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
        if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.projectileStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.projectiles.get(i).updateMovement(currentTime);
        }
      }
    }
    if (currentTime - waveStartTime >= 3000) {
      updateSpeedUp=2;
    }
    if (wrapper.player != null) {
      if (currentTime - lastAiUpdateStateOne >= (400 / updateSpeedUp)) {
        lastAiUpdateStateOne=currentTime;
        for (        int i : wrapper.priorityOneEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityOneProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
      if (currentTime - lastAiUpdateStateTwo >= (200 / updateSpeedUp)) {
        lastAiUpdateStateTwo=currentTime;
        for (        int i : wrapper.priorityTwoEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityTwoProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
      if (currentTime - lastAiUpdateStateThree >= (100 / updateSpeedUp)) {
        lastAiUpdateStateThree=currentTime;
        for (        int i : wrapper.priorityThreeEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityThreeProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
      if (currentTime - lastAiUpdateStateFour >= (50 / updateSpeedUp)) {
        lastAiUpdateStateFour=currentTime;
        for (        int i : wrapper.priorityFourEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityFourProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
    }
    if (currentTime - lastCooldownUpdate >= 100) {
      gameMode.weaponManager.updateCooldowns();
    }
    if (currentTime - lastGameModeUpdate >= 1000) {
      if (SurvivalMode.enemiesLeft == 0) {
        waveStartTime=android.os.SystemClock.uptimeMillis();
        updateSpeedUp=1;
        gameMode.startWave();
      }
    }
    try {
      Thread.sleep(20);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Suoritt�� s�ikeen.
 */
@Override public void run(){
  hud=new Hud(context);
  gameMode=new SurvivalMode(dm,context,gameActivity);
  touchManager=new TouchManager(dm,surface,context,hud);
  waveStartTime=android.os.SystemClock.uptimeMillis();
  lastMovementUpdate=waveStartTime;
  lastAiUpdateStateOne=waveStartTime;
  lastAiUpdateStateTwo=waveStartTime;
  lastAiUpdateStateThree=waveStartTime;
  lastAiUpdateStateFour=waveStartTime;
  lastCooldownUpdate=waveStartTime;
  lastGameModeUpdate=waveStartTime;
  while (running) {
    long currentTime=android.os.SystemClock.uptimeMillis();
    if (currentTime - lastMovementUpdate >= 20) {
      lastMovementUpdate=currentTime;
      for (int i=wrapper.enemies.size() - 1; i >= 0; --i) {
        if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.enemyStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.enemies.get(i).updateMovement(currentTime);
        }
      }
      for (int i=wrapper.projectiles.size() - 1; i >= 0; --i) {
        if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY || wrapper.projectileStates.get(i) == Wrapper.ANIMATION_AND_MOVEMENT) {
          wrapper.projectiles.get(i).updateMovement(currentTime);
        }
      }
    }
    if (currentTime - waveStartTime >= 3000) {
      updateSpeedUp=2;
    }
    if (wrapper.player != null) {
      if (currentTime - lastAiUpdateStateOne >= (400 / updateSpeedUp)) {
        lastAiUpdateStateOne=currentTime;
        for (        int i : wrapper.priorityOneEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityOneProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
      if (currentTime - lastAiUpdateStateTwo >= (200 / updateSpeedUp)) {
        lastAiUpdateStateTwo=currentTime;
        for (        int i : wrapper.priorityTwoEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityTwoProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
      if (currentTime - lastAiUpdateStateThree >= (100 / updateSpeedUp)) {
        lastAiUpdateStateThree=currentTime;
        for (        int i : wrapper.priorityThreeEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityThreeProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
      if (currentTime - lastAiUpdateStateFour >= (50 / updateSpeedUp)) {
        lastAiUpdateStateFour=currentTime;
        for (        int i : wrapper.priorityFourEnemies) {
          if (wrapper.enemyStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.enemies.get(i).ai.handleAi();
          }
        }
        for (        int i : wrapper.priorityFourProjectiles) {
          if (wrapper.projectileStates.get(i) == Wrapper.FULL_ACTIVITY) {
            wrapper.projectiles.get(i).handleAi();
          }
        }
      }
    }
    if (currentTime - lastCooldownUpdate >= 100) {
      gameMode.weaponManager.updateCooldowns();
    }
    if (currentTime - lastGameModeUpdate >= 1000) {
      if (SurvivalMode.enemiesLeft == 0) {
        waveStartTime=android.os.SystemClock.uptimeMillis();
        updateSpeedUp=1;
        gameMode.startWave();
      }
    }
    try {
      Thread.sleep(20);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}