File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes service() method - interesting question ???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "service() method - interesting question ????" Watch "service() method - interesting question ????" New topic

service() method - interesting question ????

vithal kambhammettu

Joined: Jul 18, 2001
Posts: 17
While in the service() method of a servlet, a secondary thread is spawned to write a long, I/O intensive, log file . If the service() method ends before the secondary thread what would happen now ???
1) The secondary thread ends when the service() method ends
2) The log file is closed when the service() method ends.
3) The service() method will wait until the secondary thread completes executing
4) The service() method ends but the secondary thread continues until it finishes
Dave Van Even
Ranch Hand

Joined: Jul 19, 2001
Posts: 101
the when the secondary method is spawned and started it keeps running till someone tells it to end !
SO, It's depending on the implementation of your service() method. I you never end the secondary thread, it will keep running.
correct me if I'm wrong...
Dave Van Even
Thomas Samimuthu

Joined: Aug 07, 2001
Posts: 8
Actualy any thread will exit when the run() method exits , so it is the programmers responsiblity to design the thread properly.

I agree. Here's the link:
subject: service() method - interesting question ????
It's not a secret anymore!