aspose file tools*
The moose likes Servlets and the fly likes init()  called at the same time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "init()  called at the same time" Watch "init()  called at the same time" New topic
Author

init() called at the same time

aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
If two threads try to acces the init method of a servlet then what will happen ?
If one thread is executing the statements in the init block of servlet, then at the same time if another request comes,then as the init is not been initialized what will happen to the request.Will the request die or wait till init is over and then call the service method.?
Regards,
aakash
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
In my opinion, since a servlet instance is not available to handle requests until the servlet container calls the initialization method, I would think this possibly unique conflict would be handled by the servlet container.
my $0.02
Craig
Kevin Jones
Author
Ranch Hand

Joined: Oct 29, 2003
Posts: 39
init will be called once and once only, So the issue of two requests entering the container concurrently, only the first request will cause the servlet to load and cause the init method to fire


Kevin Jones<br />Author: <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0321136497/jranch-20" target="_blank" rel="nofollow">Servlets and JSP: The J2EE Web Tier</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: init() called at the same time