Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

service() method - interesting question ????

 
vithal kambhammettu
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
regards
 
Dave Van Even
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actualy any thread will exit when the run() method exits , so it is the programmers responsiblity to design the thread properly.
------------------
Valan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic