How does the servlet container handle thread safety in the case of servlets?

  • By creating a new thread for each request.
  • By making the service() method synchronized.
  • By using a single thread for all requests.
  • Thread safety is the responsibility of the developer.
The servlet container handles thread safety by making the service() method synchronized to ensure that only one thread executes it at a time, preventing race conditions in shared resources.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *