• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

init() called at the same time

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic