• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One clarification on doubt regarding Servlet

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm preparing for SCWCD Exam.
I have one question regarding server which has 5 option.

Question: Identify the statement that are always true about the threads running through the service() method of a servlet with the following class declaration.(choose two).

A. The destroy() method never cuts short thread running through the service() method.

B. Threads running through service() method must run at one time.

C. There could be anything from one to many threads running through the service() method during the time of servlet is loaded.

D. If the init() ,method for the servlet hasn't run, no threads have yet been able to run through the service() method.

E. At least one thread will run through the service method if init() has been executed.

Answers: C, D


Doubts: Here i don't understand about why C --> I'm not asking that how many threads are running or i don't care about that because in multi thread model more than one thread can run at a time but my question "... during the time of servlet is loaded" how this can happen because after the servlet is loaded (loading means static initialization), instance data is initialized and after that init() is being called than how more than one thread could run duting the time of servlet is loaded!!!


Please any one help me in above.

Also suggest me which materail should i refer for better understanding and to get good score in SCWCD Exams.
 
Eurig Jones
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not entirely sure of your explanation as to why you don't understand but..

1 servlet instance in shared between many threads. The service() method is run by all of them. "... during the time of servlet is loaded" here actually means the period that the servlet is live, not when it's loading up.

E is very close to being the answer as well, but you could create a servlet and have no requests for it!

There is a slight error in this also. It states in C that there could be "anything from one to many threads running through the service()" but actually there could be 0-to-many threads.
[ September 08, 2008: Message edited by: Eurig Jones ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic