• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many instances of servlet and threads will be created

 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

When i open servlet application on ten different computers ,
1. how many nstnaces of servlet will be created
2. How many threads will be created.

Can yoou please explain me in detail.


Please. .....
 
Prasad Kumbhare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you are talking about accessing same servlet from different computers and your servlet is not implementinng Single Thread Model.

In this case only one instance of servlet will be created. Depend upon how many requests you send to that servelt, that many number of threads will be generated. If you are sending 10 requests , 10 threds will be started by the server.

If your servlet implments Single Thread Model then picture changes little bit.

Hope this helps.

Thanks
 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean to say only one servlet instance and 10 different threads.

What do you mean different in Single Thread model.
Can you give me summary of that please
 
Pawan Arora
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, SingleThreadModel was introduced in the first place for thread safety. When a servlet implements SingleThreadModel, the container guarantees that only single Thread of the Servlet would be executed in a given instance of time. Having said that, the reason for deprecating SingleThreadModel is for shouldering the responsibility of Thread safety of the servlet on the developer, without implementing SingleThreadModel. With SingleThreadModel deprecated, it becomes developer's responsibility to safe guard the non-thread safe aspects a servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic