How to make a Task complete with in 1 minute or discard it if it doesn't complete
<p>I am working on a Java EE Based application, where I need to PDF reports using itext API.
Basically my requirement is that, if the report generation takes more than 1 minute then stop it.</p>

<p>So for this I am implementing this business requirement in this way </p>

<pre><code>Thread t = new Thread(myPojoclass); 

long startTime = System.currentTimeMillis();
long endTime = startTime + 60000;

t.start();

while (System.currentTimeMillis() &lt; endTime) 
{

}

t.interrupt();  // Tell the thread to stop
</code></pre>

<p>And inside my <code>myPojoclass</code> as mentioned above, this is a Thread which implements <code>Runnable</code> interface and inside its run method it is consisting of connecting to Database 
and getting the results and giving it to an <code>ArrayList</code> </p>

<p>Please let me know if this is correct ??</p>
