title: multithreaded web application in java
body: <p>I am doing a web application which has Java as a front end and shell script as a back end. The concept is I need to process multiple files in the back end. I will get the date range from the user (for example from July 1st-8th) and for each day process around 100 files. So in total I have 800 files to process. </p>
  
  <p>I will get these details from JSP and delegate a background call to shell script and get back the results and display the same to the user.</p>
  
  <p>Now I did all these in a sequential approach - by which I mean without threads. So there is only one main thread that executes and the user has to wait till 800 files are processed sequentially. However this is really slow. And because of this I am thinking of going for threads. Since I am a beginner of threads, I read a some stuffs regarding this and I have come up with the following idea:</p>
  
  <blockquote>
    <p>As I read threads work have to be split .. I thought of splitting the
    8 day work to 4 threads where each thread would perform 2 day work</p>
  </blockquote>
  
  <p><br>
  I would like to know whether I am following a correct approach and my major concerns are:               </p>
  
  <ol>
  <li>Is it recommended to spawn multiple threads from a web application</li>
  <li>Whether or not this is a good approach</li>
  </ol>
  
  <p>Some guidance of how to proceed with this. An example instance would be great. Thank you.</p>