Hi, I have a task scheduler thread that implements ServletContextListener and starts up as a listener with the following code from my web.xml:
<listener> <listener-class> mypackage.MyServlet </listener-class> </listener> My problem is however I need this to be a singleton, its imperative. There always seems to be about 3 threads created though. I have tried numerous things including making this servlet call a singleton class to do the task scheduling but it still ends up with 3 threads. This is causing terrible concurrency problems that wouldn't exist if this was working properly. My serlvet code currently resembles the following: boolean hasBeenInitialized = false; public void contextInitialized(ServletContextEvent sce) { if(!hasBeenInitialized) { //Start up the task scheduler thread hasBeenInitialized = true; } } I am using Tomcat 4.1.18, Apache 1.3.27 under RedHat 7.3. I didn't have this problem under wn32 only Linux. Any help, or ideas on how I can get this to be a single instance would be greatly appreciated. Thank you regards, Dave