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.
So for this I am implementing this business requirement in this way
Thread t = new Thread(myPojoclass);
long startTime = System.currentTimeMillis();
long endTime = startTime + 60000;
t.start();
while (System.currentTimeMillis() < endTime)
{
}
t.interrupt(); // Tell the thread to stop
And inside my myPojoclass
as mentioned above, this is a Thread which implements Runnable
interface and inside its run method it is consisting of connecting to Database
and getting the results and giving it to an ArrayList
Please let me know if this is correct ??