Hi, I would like to run a program that loops forever, in the background, when Tomcat starts. I created MyServlet.java, and in its init() method, I included the following code...
Thread t = new Thread();
So basically the code will output "Hello world!" to the console every minute.
In my web.xml, I included the following tag...
So my Tomcat will execute MyServlet when it starts.
The problem is that I can't access the web application at all since MyServlet is still running. Since it will run continuously until the Tomcat shuts down, that means I can't access the web application at all. How do I run a program, that loops continuously, in the background, whenever Tomcat starts, and which will not affect the other servlets in my web application? Thanks!