Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SingleThreadModel

 
Latha Kota
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have come across this question in HFSJ mock exam. It says that this statement is true. Can anybody explain me why?

If the servlet does not implement SingleThreadModel, the container will create no more than one instance per JVM.

Thanks,
Latha.
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this statement is correct.

If we dont implement SingleThreadModel, then there will be only one instance of the servlet which will serve all the request.

If we implement SingleThreadModel, and we have to server 5 request simultaneously, only then we can do the configuration of creation of more than one instance of the servlet.
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

essentially if the Servlet does not implement SingleThreadModel then the server considers it to be thread safe, and thus all requests the go to the same instance of the servlet in different threads. This means, that at any one point in time, there may be more than one thread executing through the same servlet.

HTH

Mat
 
Latha Kota
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kapil and Mat. I now understood it better.
Latha
SCJP 1.4
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic