title: Stopwatch in Java with a resetting function
body: <p>I have implemented a SIP Servlet, where I receive two types of messages from the clients. I can receive either a high priority message and low priority message, which I separate when I'm reading the URIs of the messages as shown in the code below. I have to implement a basic stopwatch, which increments the "count" integer declared in code below. How do I make such a stopwatch and resetting it ?.  </p>
  
  <pre><code>protected void doRequest(SipServletRequest reqfromclient) throws javax.servlet.ServletException, java.io.IOException {
      if( reqfromclient.getMethod().equals("MESSAGE") ) {
          String MESSAGE = reqfromclient.getContent().toString();
          System.out.println("The arrived message is " + MESSAGE);          
  
          // Assign the callee URI
          String URICallee = reqfromclient.getTo().getURI().toString();
  
           //Assign the caller URI
          String URICaller = reqfromclient.getFrom().getURI().toString();
  
  
          //DECLARE STOPWATCH
          int count = 0;
  
  
          // Now the Highprio and Lowprio alerts have to be separated
          if(URICallee.endsWith("policeHigh.com")) {
              // RESET STOPWATCH
              //START THE STOPWATCH. INCREMENT COUNT EVERY SECOND
          }
  
          else if(URICallee.endsWith("policeLow.com")) {              
              if(count == 21) {                   
              //something
              }
          }
      }
  </code></pre>