In my J2EE application, I need to start a thread for performing some timed tasks (what I need is a very basic job scheduler). I am going to use a java.util.Timer, started somewhere in the lifecycle of a servlet and closed in the destroy method of the same servlet.
Here and there I read that starting new threads in a J2EE environment is not desirable, since --if I got it right-- these threads would not be directly controlled by the application server.
1) What does it actually mean? What kind of problems could I face with this approch?
2) Should I use a daemon or a user thread?
(I know there is a J2EE version of Timer, but I can not use it, due to version and other project constraints)
Can you to use Quartz? (http://www.opensymphony.com/quartz/
One of the problems of creating custom threads is that the thread won't have the container's security context set (amongst others). This might however not be a problem for you. But beware that the InitialContext for EJB lookups, etc, might not function correctly (depending on your app server implementation)
1) Apart from the missing context, I see no problem with the thread not "beeing managed by the application server". Just be sure to manage it correcly yourself, i.e. destroying it where appropriate, etc, and other normal threading related issues.
2) It does not matter, as long as you do the resource handling correctly.