Java: How to wait until a screenshot is captured before taking a new one
<p>I have written java code that captures a screenshot. User can set a time duration in seconds, e.g. 20 seconds, then after 20 seconds screenshot of current working application will be taken. Now I want to improve code by allowing user to set Number of screenshots to be captured in sec like if user sets <code>ImageCnt=5</code> then 5 screenshots should be taken after  every 20 sec.the code is like ....</p>

<pre><code>int cnt = ImageCnt;

while(cnt!=0)
{
   timerclass t=new timerclass(Time);//captures screenshot after specified Time
   cnt--;
}   
</code></pre>

<p><strong>My Problem is in this code. I want that second screenshot should not be captured before the first is completed and third should not be captured before 2nd is completed  and so on........
In my code it simultaneously captures all screenshot.</strong>           </p>
