Single Thread Model

  • Single Thread Model is Marker Interface.Because It defines no constants and declares no methods.

  • It used to indicate that only a single thread will execute the service( ) method of a servlet at a given time.

  • It restrict access of more than one user at a same time.

  • In this Model servlets handle only one request at a time.No two threads will execute concurrently in the service method of servlet.

  • It use where Multiple requests accessed multiple threads at the same time,for avoiding instance variable or synchronizing of code accessing those threads.

    It uses two approaches for thread Safety:-
  1. Instance Pooling
  2. Sequential Processing
Instance pooling:-
  • It maintains a pool of servlets by Servlet Container.

  • Each thread uses a free servlet instance from the pool.
Servlet Pooling
Sequential processing:-
In Sequential Processing,new requests will wait while the current request is being processed.