Consider a scenario in which 4 users are accessing a servlet instance. Among which one user called destroy() method. What happens to the rest 3 users?

Showing Answers 1 - 11 of 11 Answers

ravi

  • Nov 27th, 2005
 

Hi,

We know that by default servlet is multithreaded, for every client request a new thread will be created and assigned to that to perform the service. so if one thread initiates destroy() only itself will be terminated but  other threads not terminates.

Other wise, it is against to servlet spec. regarding multithreading concept. ex: suppose if u open 2 browser instances for a website, if u move from one site to another in one browser the other remains connect to same site not terminates.

  Was this answer useful?  Yes

K M Rameshkumar

  • Jan 12th, 2006
 

This is not possible as the destroy() can only invoked by the container, Which always makes sure there is no client is being processed before executing destroy().

sampra

  • Mar 4th, 2008
 

if there are 4 user and one has distroy the thred then thread which he is using only that will be distroy rest will be keep alive

  Was this answer useful?  Yes

Janga Yella Raju

  • May 25th, 2013
 

Calling destroy method by himself. Doesnt means destroying the servlet. Container will take care to destroy the servlet when application undeployed or system shut downs.

So, if 1 user calls destroy method within its service method. it will not destroy the servlet. other thread can still access the same servlet instance.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions