This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Eclipse Collections Categorically: Level up your programming game and have Donald Raab on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

SingleThreadModel

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kapil and Mat. I now understood it better.
Latha
SCJP 1.4
 
permaculture is largely about replacing oil with people. And one tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic