title: Do something, if takes longer than x seconds continues with the next task
body: <p>I am a Java beginner searching for a way to do the following:</p>
  
  <ol>
  <li>Read from a csv file (csvreader) one line at a time.<br></li>
  <li>Do some process with the data from the previous step.<br></li>
  <li>If takes longer than 30 seconds, skip the process and continue with the next line.</li>
  </ol>
  
  <p>I'm having problem with step 3.
  Do I need to set a timer for this?
  Do I need to play with my try and catch?
  What do you suggest?</p>
  
  <p>This is a brief of my code:</p>
  
  <pre><code>public static void main(String[] args) throws IOException, InterruptedException{
  
      CsvReader data = new CsvReader("data.csv");
      data.readHeaders();
  
      int index = 1;
      int index_max = 50;
      int retry = 0;
      int retry_max = 2;
  
      while (index &lt; index_max)
      {           
          if (retry == 0)
          {   data.readRecord();
  
              String Column1 = data.get("COLUMN1");
              String Column2 = data.get("COLUMN3");
              String Column3 = data.get("COLUMN4");
              ...
          }
          else
          {
              //Retry with the same data
          }           
  
          try {
              //Invoke webservice to send the data and write on DB after validation 
  
                  if (positive.answer == 0)
                  {
                      System.out.println("Great!!!");
                      index++;
                      retry = 0;
                  }
                  else
                  {
                      System.out.println("Bummer");
                      index++;
                      retry = 0;
                  }
              }                       
          catch (Exception e) {
              if (e instanceof webservice_Exception){
                 //The Exception is about the webservice, print it
                 index++;
                 retry = 0;
              } else {
                 //The Exception is about another thing, could be a transmission issue, please retry
                 retry++;
                 if (retry == retry_max)
                 {
                  retry = 0;
                  index++;
                 }                   
              }
          }
      }
      data.close();
  }
  </code></pre>