dcsimg
Blocking the applet and main threads ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   BW_T
Posted On:   Sunday, October 16, 2005 11:00 PM

The thread that runs the Applet callback methods like init() and start() is a thread named “applet-your.package.your.classname.class”.



If I am doing a blocking method call, i.e. a method call that does not return immediately like doing I/O read on a socket connection, is it ok to do it on the thread mentioned above ? In other words, is it ok to hang/suspend/block the applet thread ?



What about blocking the “main” thread that calls

public static void main(String args[]) {…}

?


Thanks.

Re: Blocking the applet and main threads ?

Posted By:   Anonymous  
Posted On:   Thursday, November 24, 2005 06:57 AM

Hi,


Your servlet's service() method (I assume that is the method you wish to do your heavy-duty thread-blocking processing on) is called by the ServletContainer.

Although officially vendor-specific, all vendors I know do this by some sort of thread pool.


Therefore, you can block your servlet's methods, provided that:


  1. there are enough 'free' threads in the pool to service new, incoming requests for this or other servlets (this can usually be tuned/configured).

  2. you block the service() method short enough so the browser does not assume a timeout.




Blocking the 'main' thread is just blocking the 'main' thread the VM created to run your program in (i.e. the program does not exit until main is finished). So in short, your program just keeps running.

About | Sitemap | Contact