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

when destroy method is called

 
sai prasanna
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

destroy method is called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed. how container knows that all the threads are exited and where we specify the timeout period for a servlet.

thanks in advance
saiprasanna
 
sandy li
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I learn a lot from your words.
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know how other servlet containers do the job, so I'll give you overview how I implemented this in my servlet container.
1. All servlets create threads in certain thread group servlet container assigned them
2. Upon receiving termination signal, a servlet container sends an interrupt signal to all groups assigned for servlets
3. Servlet container enumerates all thread in groups and checks if they are still alive, if no alive go to 5
4. Servlet container is enumerating threads again after timeout time reached and destroys all still active threads
5. Servlet container calls destroy of all servlets
6. Servlet container exits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic