• 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: 3381
12
  • 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
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!