Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SingleThread Model is deprecated in 2.4

 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
1) What is the advantages/disadvantages of using Single Thread Model.
- I feel instead of implementing SingleThreadModel we can put the particular codes in the synchroized block, which avoids the overhead. Am I correct?
2) What is the advantages of using Instance pooling model instead of single instance request model?
3) Since SingleThreadModel is deprecated then whether Servlet instance pooling model is still available? If so how to configure instance pooling in the weblogic server.
Thanks & Regards,
M.S.Raman.
 
praveenkumar singamsetty
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...this is what was written in java.sun.com
RonCrawford_II: Why is the SingleThreadModel interface and option in JSP when the Java platform offers the synchronized keyword? What are the benefits of placing synchronization on the JSP engine?
Marty: Well, SingleThreadModel gives the server more flexibility than you would have if you manually synchronized all your code in service or _jspService. For example, a server can queue up requests to a single servlet instance or make multiple servlet instances and send requests concurrently (as long as a single instance gets only one request at a time). That all being said, I do agree that in general it is better NOT to use SingleThreadModel and to synchronize access to shared data yourself.

bye dude
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) What is the advantages/disadvantages of using Single Thread Model.
I can't see any advantage. Disadvantage, many. The main one, performance.
- I feel instead of implementing SingleThreadModel we can put the particular codes in the synchroized block, which avoids the overhead. Am I correct?
hmmm yes. But it also depends on what exactly you want to sinchronize. For instance, it doesn't make sense to synchronize the service() method.
2) What is the advantages of using Instance pooling model instead of single instance request model?
what is "instance pooling model?". If your talking about SingleThreadModel, then the container may create several servlet instances and each thread will execute on its own instance.
3) Since SingleThreadModel is deprecated then whether Servlet instance pooling model is still available? If so how to configure instance pooling in the weblogic server.
SingleThreadModel is deprecated in servlet 2.4 only. I'm not sure whether there are servlet containers that create multiple instances of a servlet when running with multithread model. You shouldn't configure instance pooling, I think that's the container's job. Your job is to make sure that the servlet is thread safe, without the need of implementing SingleThreadModel (using local variables, avoiding static variables, etc).
hope this helps
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andres Gonzalez:
1) What is the advantages/disadvantages of using Single Thread Model.
I can't see any advantage. Disadvantage, many. The main one, performance.
- I feel instead of implementing SingleThreadModel we can put the particular codes in the synchroized block, which avoids the overhead. Am I correct?
hmmm yes. But it also depends on what exactly you want to sinchronize. For instance, it doesn't make sense to synchronize the service() method.
2) What is the advantages of using Instance pooling model instead of single instance request model?
what is "instance pooling model?". If your talking about SingleThreadModel, then the container may create several servlet instances and each thread will execute on its own instance.
3) Since SingleThreadModel is deprecated then whether Servlet instance pooling model is still available? If so how to configure instance pooling in the weblogic server.
SingleThreadModel is deprecated in servlet 2.4 only. I'm not sure whether there are servlet containers that create multiple instances of a servlet when running with multithread model. You shouldn't configure instance pooling, I think that's the container's job. Your job is to make sure that the servlet is thread safe, without the need of implementing SingleThreadModel (using local variables, avoiding static variables, etc).
hope this helps

Thanks praveenkumar singamsetty , Andres Gonzalez.
Regards,
M.S.Raman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic