title: How to show the values in the LOOP for every 10 second in java
body: <p>I have a while loop where in it constructs a JAVA String by appending the output from a shell script. </p>
  
  <pre><code>System.out.println("Here is the standard output of the command:\n");
  while ((s = stdInput.readLine()) != null) {
  refreshString = refreshString + s;
  System.out.println(s);
  }
  </code></pre>
  
  <p>This shell script takes 2hrs to execute. Is there a way by which I can grab the string every 10 seconds(Snapshot of the current string)? I am developing a JAVA application where in I need to display that string on the browser every 10 seconds.(I am doing that by using Auto Page Refresh Library. The page automatically refreshes.)</p>
  
  <pre><code>public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  ...
  PrintWriter out = response.getWriter();
  ...
  out.println(refreshString);
  </code></pre>
  
  <p>Now my page has to display current "refreshString" every time the page refreshes.</p>
  
  <p>Just let me know if my question isn't clear.</p>