int  nbOfTransitions; int  next; long time; long startSession, endSession;
int  nbOfTransitions=0; int  next=0; long time=0; long startSession=0; long endSession=0;
  public void run()  {    int  nbOfTransitions;    int  next;    long time;    long startSession, endSession;    while (!ClientEmulator.isEndOfSimulation())    {      // Select a random user for this session      userId = rand.nextInt(rubis.getNbOfUsers());      username = "user"+(userId+1);      password = "password"+(userId+1);      nbOfTransitions = rubis.getMaxNbOfTransitions();      if (debugLevel > 2)        System.out.println("Thread "+this.getName()+": Starting a new user session for "+username+" ...<br>");      startSession = System.currentTimeMillis();      // Start from Home Page      transition.resetToInitialState();      next = transition.getCurrentState();      while (!ClientEmulator.isEndOfSimulation() && !transition.isEndOfSession() && (nbOfTransitions > 0))      {        // Compute next step and call HTTP server (also measure time spend in server call)        lastURL = computeURLFromState(next);        time = System.currentTimeMillis();        lastHTMLReply = callHTTPServer(lastURL);        stats.updateTime(next, System.currentTimeMillis() - time);        // If an error occured, reset to Home page        if (lastHTMLReply.indexOf("ERROR") != -1)        {          if (debugLevel > 0)            System.out.println("Thread "+this.getName()+": Error returned from access to "+lastURL+"<br>");          stats.incrementError(next);          if (debugLevel > 1)            System.out.println("Thread "+this.getName()+": HTML reply was: "+lastHTMLReply+"<br>");          transition.resetToInitialState();          next = transition.getCurrentState();        }        else          next = transition.nextState();        nbOfTransitions--;      }      if ((transition.isEndOfSession()) || (nbOfTransitions == 0))      {        if (debugLevel > 2)          System.out.println("Thread "+this.getName()+": Session of "+username+" successfully ended<br>");        endSession= System.currentTimeMillis();        long sessionTime = endSession - startSession;        stats.addSessionTime(sessionTime);      }      else      {        if (debugLevel > 2)          System.out.println("Thread "+this.getName()+": Session of "+username+" aborted<br>");      }    }  }