Hi
Here is a snippet of some simple code. Basically, the servlet creates a new thread, starts it, then continues and echoes back to the screen "BPD Running". I've not included the other classes, as they aren't relevant at the moment. Also, note this is a very simple servlet that I'm playing with to get a handle on how servlets/threads can be used together. I'm looking at spawning several threads in a later project, that need to be kicked off from a web invocation, hence the servlet.
What I can see from debug output is that the BPDThread is created and runs correctly, fulfilling its own task correctly. The problem is that on a subsequent page request to the same servlet, the servlet hangs, and Tomcat locks up.
I've noted that by stepping through on debug, on the SECOND request, when I get to bpd.start(), the system locks up.
public class ThreadPollServlet extends HttpServlet {
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
SearchBean searchBean = new SearchBean();
searchBean.setEmsId("7024");
searchBean.setSwiftId("65452");
BPDThread bpd = new BPDThread(searchBean);
bpd.start();
res.setContentType("text/html");
ServletOutputStream out = res.getOutputStream();
out.println("<html>");
out.println("<head><title>BPD Process running in background</title></head>");
out.println("<body>");
out.println("<h1>BPD Running</h1>");
out.println("</body></html>");
}
}
Any ideas?