• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JWebplus : Question ID :1000056254950

 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q. A servlet implements SingleThreadModel interface. The servlet container may run multiple threads on its methods.

True or False ?
I answered False....but in JWeb..it is True ? Why ?
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct answer is indeed given as false. The explanation is also given:

No, the container cannot let multiple threads execute the methods of the same instance at the same time. This is guaranteed by the specification. To support multiple user requests, the container may create multiple instances of this servlet.

I don't see any correct history for this question either.
HTH,
Paul.
 
no more user
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can run multiple threads, however not in the same time..
its a trap question, i dont want to get this in the exam!!
 
no more user
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a doubt!
if a servlet implements SingleThreadModel, all your methods are to one thread, not only the service method.
its right??
 
Jacky Chow
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
How about create threads in service() method ?
 
Stephen Batsas
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Nazmul,
Hi how are you? I remember you were studying for SCPJ2 around same time as me Jan this year. Im just bought Webplus to start prep for exam.
Refer to your question - SingleThreadedModel
my references state:
when your servlet implements this interface - the server queues up all the request threads passing them one at a time to the servlet instance.
So the answer is true from this perspective.
Regards
Stephen
SCPJ2
 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Stephen
Yes..I do remember you. How are you ? I'm going to sit for SCWCD next 28/30th Sept. Still I have few problems
You are right. Servlet container will pass multiple request one by one. But there is only one instance of the servlet..right? May be multiple instance to serve multiple request. But no multiple thread of same servlet instance. So the answer should be false.
And "can run multiple threads, however not in the same time..
" ...if so...then what is the advantage of thread
Anyway...hope not to face such tricky question
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic