What is single thread model and multi thread model in servlet?

Container create one or more servlet instance depending on which servlet model you are using.
There are two servlet model:
  • Single Thread Model
  • Multi Thread Model
Single Thread Model:
To follow single Thread model your servlet class has to implement interface called SingleThreadModel.It is a marker interface.
In the case of single Thread Model servlet instance will be created for every incoming request that is multiple servlet instance will be created for Single Thread Model.
It is not recommendable to use SingleThreadModel because multiple instance of a servlet will not be reused. So no use of maintaining many instance for long time. This is may be cause the problem like performance & memory wastage.

Multi Thread Model
By default container follows Multi Thread Model.
Only one servlet instance will be created and the same instance will be used to provide the service to every incoming service.
It is always recommended. 

3 comments :

  1. Nice Article ... Please explain it in details if possible. And plz give example of how to implement single thread model and multi thread model.

    ReplyDelete
  2. Howdy, would you mind letting me know which web host you’re utilizing? I’ve loaded your blog in 3 completely different web browsers, and I must say this blog loads a lot quicker than most. Can you suggest a good internet hosting provider at a reasonable price?
    Best AWS Amazon Web Services Training in Chennai | Best AWS Training and Certification for Solution Architect in Chennai
    Amazon Web Services Training in Tambaram, Chennai|Best AWS Training in Tambaram, Chennai

    ReplyDelete
  3. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
    python course institute in bangalore
    python Course in bangalore
    python training institute in bangalore

    ReplyDelete