title: How to stop a command being executed after 4-5 seconds through process builder?
body: <p>Reference code :</p>
  
  <pre><code>ProcessBuilder ps4;
  Process pr4 = null;
  
  String batchFile3 = new File(path + "/src/example.sh");
  
  ps4 = new ProcessBuilder(batchFile3.getAbsolutePath());
  
  ps4.redirectErrorStream(true);
  ps4.directory(new File(path + "/src/"));
  
  pr4 = ps4.start();
  
  BufferedReade readRun = new BufferedReader(new InputStreamReader(pr4.getInputStream()));
  
  
  
  if(pr4.waitFor()==0)
  {
  
  }
  
   String line,stre;   
  
  while ((line = readRun.readLine()) != null) {
  
       System.out.print("-----" + line);
  
       if (line != null) {
  
             stre += line;
  
      }
  
  }
  </code></pre>
  
  <ul>
  <li><p>Here I have result in stre string it might be error or output generated by batch file which I am executing.</p></li>
  <li><p>I want to stop execution of batch file if it is taking more that 4-5 seconds to exectute and kill that batch file execution process.</p></li>
  <li><p>also in that case I should be able to return back to program to process a block which will execute only if this delay in processing of batch file occurs other wise that block should not be processed.</p></li>
  </ul>