Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about 'single-threaded mode'

 
Tiffiny Yang
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mock QUESTION :
If a servlet is designed to execute in single-threaded mode as part of a distributed Web application, which is true?
A. The servlet container must only instantiate one instance of the servlet within each Java Virtual Machine.
B. The servlet definition in the Web application deployment descriptor must include the element.
C. The servlet container may instantiate multiple instances of that servlet in each Java Virtual Machine within the container.
D. The servlet container manages the thread-safety of the session object within each of the Java Virtual Machines in the distributed application.

The answer is C.
Can anybody explain why? and Is the single-Thread related questions on the exam ?

Thanks in advance
 
PRavi kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The SingleThreadModel is not in Exam.
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one single instance of a servlet in a JVM. So, in that context i think even 'a' is correct.
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not so sure.
I'm sure I remember getting an old mock question wrong once as the JVM was free to make as many instances of the servlet as it wanted, provided each was only handling one thread at once.

Open to correction.
 
Manwatkar Vaibhav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to me, Answer C is correct because..

In Single Thread Model of Servlets, for each request, an Instance of that Servlet is newly created or an Instance from the Container Managed Pool is allocated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic