Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

meaning

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello

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 .

gaurav
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to ask questions:
http://www.catb.org/~esr/faqs/smart-questions.html

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

Now to a meaningful answer: 42.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Mark
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Bill
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic