This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes meaning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "meaning" Watch "meaning" New topic


gaurav chhabra
Ranch Hand

Joined: Jul 24, 2004
Posts: 109

what does the below statement means and how it is possible -:

There may still be threads that execute the service method when destroy is called, so destroy has to be thread-safe .

Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
How to ask questions:

Including a meaningful topic will help you get a meaningful answer.

Now to a meaningful answer: 42.

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

Well if you have threads that may call the service and you are in the middle of calling destroy to remove the instance there can be problems, like the resurection of the Servlet and some others. So by making the destroy thread-safe, you make sure that you have a lock of the object, therefore disallowing any other calls to the object while you are in the destroy.

This also means that the thread that may call the service method needs to handle the possibility that the object is no longer in existence.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12682
Note that the servlet API says that a servlet container will only call destroy "once all threads within the servlet's service method have exited or after a timeout period has passed."
Once destroy has been called, the container should not send any more requests to the service method, no matter what destroy did.
I agree. Here's the link:
subject: meaning
Similar Threads
ServletException from destroy( )
when is destroy called
Tomcat restarted and session still work?
what are container callback methods??
WA #1.....word association