-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Cid,
On 1/9/2011 11:27 AM, Captain Cid wrote: > I am having a CXF webservice impl class. In this I want to start a new thread > in service impl constructor. This is because I need to run a thread will > continuously do some operation in background using database. And I need to > be able to stop it when tomcat is shutdown. If you only need a single thread to run all the time go ahead and create it in a ServletContextListener (or via a Spring-manager object if you want). Just remember to stop the thread, later. > I was searching net. Found that it can be done using executor etc. But still > I am unable to find it. Any help appreciated. If you need to run more than one thread, I highly recommend using an executor: you can submit a job to a ThreadPoolExecutor and it will be run when there is a free thread. This helps limit your resource usage even under load: that is, you won't be firing off hundreds of threads if you get swamped by requests that need to schedule background jobs. Instead, your job queue simply grows longer. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0ra9IACgkQ9CaO5/Lv0PDa4QCeMI3XSO399vP6Hsc040KuB3oo pFgAoKzVj3Rb1R4bdiiX/NzbABsWWwca =AFKb -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org