Hi,
I want my
servlet to start a new
thread that will call one simple method once a day and sleep the rest of the time and run indefinitely.
At the moment I have got the code for creating the thread in the init() method of the servlet:
public class MyServlet extends HttpServlet implements Runnable
{
private Thread thread = (Thread) null;
public void init()
{
MyServlet app = new MyServlet();
if ( this.thread == null )
{
thread = new Thread ( app );
thread.start();
}
}
}
and then I visit the servlet in the web browser to kick the thing off.
Is this the right way to do this - creating a new instance of the servlet in the init method and spawing a new thread from this?
Many thanks,
Peter