Header Ads

  • Breaking Now

    How do you make servlet thread-safe?

    SingleThreadModel interface once implemented makes a servlet thread safe,though not in complete sense.It ensures that servlet handles only one request at a time. In this case only one thread will be able to execute service() method at a time.Though it affects the performance of the servlet to a great extent. In STM container creates multiple instances of servlet.This interface is deprecated from Servlet API version 2.4.

    It does not resolve all thread safety related issues of a servlet, as most of session attributes and static variables can still be shared across multiple threads at the same time.The other ways to handle such situations can be avoid creating instance variables or synchronizing the block of code accessing those resources.

    Post Top Ad

    Post Bottom Ad