> --------------------------------------------------------------- > Rule of Thumb: If an applet performs a time-consuming task, > it should create and use its own thread to perform that task. > ---------------------------------------------------------------' > > No reason _not_ to create threads in applets!
You shouldn't just create a thread for the heck of it in a any situation that I know about. If you really need one, then spawn one. But, see below. > > And _many_ reasons not to do this in managed environments > like Servlet containers and EJB containers! The fact that the browser environment is unmanaged is an even stronger reason to use a lot of thought before creating a thread. Since you don't even know which browser you will execute in, or when the user may choose to terminate the applet, starting threads that own things ( like connections and locks) opens you up to all kinds of situations that can hang browsers or deplete system resources ( probably not as big an issue as it is on the server, admittedly). It may be easier to have a few users restart browsers than to restart a servlet container, but it is still a bad result. > -----Original Message----- > From: Anthony Tagunov [mailto:[EMAIL PROTECTED]] > Sent: 2002,January.02.Wednesday 7:57 AM > To: [EMAIL PROTECTED] > Subject: Re: Applet:Servlet using streams in a thread > > > Hello Mike! > > MM> fwiw, spawaning threads in an applet isn't a real good > idea either. > > isn't it? > > this is from the java tutorial from sun.java.com > > > 'So why would an applet need to create and use its own threads? > Imagine an applet that performs some time-consuming initialization > -- loading images, for example -- in its init method. The thread > that invokes init can not do anything else until init returns. > In some browsers, this might mean that the browser can't display > the applet or anything after it until the applet has finished > initializing itself. So if the applet is at the top of the page, > for example, then nothing would appear on the page until the applet > has finished initializing itself. > > Even in browsers that create a separate thread for each applet, > it makes sense to put any time-consuming tasks into an applet-created > thread, so that the applet can perform other tasks while it waits for > the time-consuming ones to be completed. > > --------------------------------------------------------------- > Rule of Thumb: If an applet performs a time-consuming task, > it should create and use its own thread to perform that task. > ---------------------------------------------------------------' > > No reason _not_ to create threads in applets! > > And _many_ reasons not to do this in managed environments > like Servlet containers and EJB containers! > > Best regards, Anton > > ______________________________________________________________ > _____________ > To unsubscribe, send email to [EMAIL PROTECTED] and > include in the body > of the message "signoff SERVLET-INTEREST". > > Archives: http://archives.java.sun.com/archives/servlet-interest.html > Resources: > http://java.sun.com/products/servlet/external-resources.html > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html > > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html