Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multithreaded and SingleThreadModel

 
Jack Lau
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Since servlet by default is using multithread, multiple threads can access same servlet simutanously. Is there only one instance of each servlet (e.g. servletA) exists in the servlet container?

Also if implements SingleThreadModel, does it create more than one servlet (e.g. servletA) if there are more than 1 request?

Thanks,
Jack
 
Mikalai Zaikin
Ranch Hand
Posts: 3332
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack ,

Yes, by default only 1 instance of each Servlet exists in Servlet Container and serves multiple threads simultaneously.

If SingleThreadModel implemented, there are 2 options:
1) create pool of servlet instances and pass new request to new instance
2) serialize incoming request and put it in the queue to one servlet instance

1), or 2) - depends on servlet container implementation.

regards,
MZ
 
Jack Lau
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!
Jack
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic