title: wait() before next iteration in a for loop java
body: <p>What I'm trying to do here is to upload files one by one. For example, if my file list contains 2 files ready to upload, I want to upload the second file once the first is uploaded and created.</p>
  
  <p>Actually, I loop the file list and upload the file from each iteration whitout waiting the last upload to finish.</p>
  
  <p>Here is an idea of what I'm excepecting  :</p>
  
  <pre><code>for(FileContainerBean fileContainer:fileContainerList){
  
      FileUpload fileUpload=new FileUpload(fileContainer.getFile());
      Thread th=new Thread(fileUpload);
      th.start();
  
      //Now i want here to wait beafore moving to the next iteration
  
      while(!fileContainer.isCreated(){
            wait();
          }
      if(fileContainer.isCreated(){
         notify();
        }
  }
  </code></pre>
  
  <p>fileContainer is a bean with getters and setters (setFile,getFile,isCreated....).</p>
  
  <p>When the upload is over and the file is created ( HttpResponseCode=201), fileContainer.isCreated=true. Initially, isCreated=false;</p>
  
  <p>I hope that I'm clear enough ! So is it possible to do that ?</p>
  
  <p>Thanks in advance !</p>
  
  <p>Ismail</p>