Discussions

Web tier: servlets, JSP, Web frameworks: Can service method be synchronized

  1. Can service method be synchronized (2 messages)

    HI!

    Can we define a synchronized block in service method of servlet.What will happen?Generally to make our servlet thread saf we will implement singleThreadModel interface which is nothing but synchronizing.If we do the same in service ie.,defining synchronied block in service.What'll happen?

    Regards.
    Vijaya.
  2. Hi!
        If service method is synchronized instead of using SingleThreadModel interface by synchronizing the block some of the variables like session variables and static variables cannot be accessed by dirferent threads simultaneouly
        If you use SingleThreadModel it will not guarantee the synchronization of these variables
        Any suggestions or queries mail to me at nnareshkumar at seznam dot cz

    Thanks,
    N.NARESH KUMAR
  3. ThanQ Naresh.

    Regards.
    Vijaya.