Hi all,
does anybody know if starting a new thread (in order to perform time expensive operations) inside a servlet o a portlet can cause problems ?
Thanks
Davide
-
Starting thread inside servlets (2 messages)
- Posted by: Davpoz Davpoz
- Posted on: January 08 2004 12:23 EST
Threaded Messages (2)
- Starting thread inside servlets by Paul Strack on January 08 2004 18:47 EST
- Starting thread inside servlets by David Rabinowitz on January 09 2004 08:53 EST
-
Starting thread inside servlets[ Go to top ]
- Posted by: Paul Strack
- Posted on: January 08 2004 18:47 EST
- in response to Davpoz Davpoz
For the most part, no. The only possible issue is that your security context may not propogate correctly for operations performed inside the thread. This will probably only be an issue if your servlet invokes an EJB, and expects the web authentication information to propogate to the EJB layer.
Otherwise, you are probably safe. -
Starting thread inside servlets[ Go to top ]
- Posted by: David Rabinowitz
- Posted on: January 09 2004 08:53 EST
- in response to Davpoz Davpoz
I don't think so, and I know the old version of the server at my previous company did it. But, it is considered bad programming style. If you have servlet container, then he manages the threads, not you. Also, it is not very scalable. I'd suggest using one of the two:
* Use thread pool
* Use JMS for asynchronous tasks
David