-
1. Re: Spawning threads in server process
starksm64 Dec 26, 2005 9:35 AM (in response to kevinstembridge)Its generally fine to use threads as long as you take responsibility for how they interact with the container/ejbs. There are some mbean services that provide thread pools that can simplify basic thread management:
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigBasicThreadPool -
2. Re: Spawning threads in server process
kevinstembridge Dec 26, 2005 6:15 PM (in response to kevinstembridge)thanks Scott, I'll check it out.
-
3. Re: Spawning threads in server process
rsaraf Mar 3, 2006 12:34 PM (in response to kevinstembridge)For a Jboss based application I am working on, I want to do a very time consuming task on the EJB side. The task cannot be made faster as it is serial in nature. All I can do to improve the response time is to break the task into smaller pieces. Using JMS queues will be an overkill for the application of that nature. So I was inclined to use threading and wanted to spawn threads from the servlet which will call the service on the EJB side. I want to spawn threads from a request thread and wait for all the threads to return to be able to accumulate the results and send it back in my servlet response.
Can someone suggest a way to do this through threading, also are there any examples or code snippets someone can point. -
4. Re: Spawning threads in server process
jimbrady Dec 18, 2007 11:48 AM (in response to kevinstembridge)I have a similar request, and this thread seems to have died. I have started threads from a servlet and it works well (using a global maps and the rule one per user, one per task). My problem is how to manage the security aspect, and Scotts answer really answer that (nice to see there is a pool of threads - but how do you use it)? I have noticed that if the request is terminated the thread keeps running but the security environment has vanished. Ideally, I would like to spawn a servlet as a new independent background request within the same session. Is there a way to do this. Essentially TOMCAT is setting up the environment when a thread is started (Thread pool?) and this environment will change when TOMCAT moves on to something else. If I am just using unsecured reads I don't have a problem, but I am not keen of having database updates labelled "nobody".