This is definately not true. You need to make a distinction between web containers and 
EJB containers, or to be more specific EJBs
themselves. There are some restrictions on EJBs with respect to threading. I'm not 
sure what they are exactly. But creating your own
threads is perfectly fine in web containers like Tomcat.

For example, for most of my Struts apps I have an initApplication servlet that runs on 
startup and loads some objects from the
database into the application scope. Sometimes I spin off a thread from the init 
method that hangs around for the life of the app
and periodically reloads the objects from the database. I probably could have 
subclassed ActionServlet and spun this thread off from
the init method there.

Sean, you could do the same thing with your Service thread. You don't need to turn it 
into a servlet.

Will

----- Original Message -----
From: "Paul Tindall" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 03, 2001 3:37 PM
Subject: Re: Servlets, Beans, Struts, and Threading


> Sean,
>
> It is my undertanding that you do not want to do your own threading anywhere
> within a J2EE container as bad things can happen.  If you need to create a
> timer process to kick off other communication processes, WebLogic and Resin
> both have them and the containers will manage the threads.  These timer
> features are not part of the J2EE standard so I'm not sure about Tomcat or
> other containers and what level of support they might have.
>
> Regards,
>
> Paul
>
>
> ----- Original Message -----
> From: "Sean" <[EMAIL PROTECTED]>
> To: "Struts Users" <[EMAIL PROTECTED]>
> Sent: Thursday, May 03, 2001 10:31 AM
> Subject: Servlets, Beans, Struts, and Threading
>
>
> > Hello All,
> >
> > This is a simular question I asked on the Tomcat mailing list and never
> got
> > a reply.  I was hoping someone could give me some good input on this topic
> > from this list.
> >
> > If I have a process that needs to run within Tomcat&Struts to communicate
> > with a remote server, and that process needs it's own thread of execution,
> > what would be the best way to go about this in the Tomcat/Servlet
> container
> > world?  I am not sure if each Servlet has it's own thread of execution so
> I
> > wasn't sure if I should just subclass Servlet or HttpServlet.  I am not
> sure
> > of the ramifications of having a bean manage it's own threads and how that
> > would effect Tomcat in general.
> >
> > Does anyone have any pointers, ideas, or suggestions on how they have done
> > this or would go about doing this nicely in Tomcat?  Would this be cross
> > container code or Tomcat specific?
> >
> > Thanks,
> > Sean
> >
>

Reply via email to