SingleThreadModel Interface

Hello here,

I am curious what really happens when we actually implements the SingleThreadModel Interface

It does not have any methods that we need to implement.

so what is really happening when i actually do that?

Also I note that even when i implements the SingleThreadModel Interface in the class,

the methods in the class have to be synchronized for .. can anybody explain the reason?

is SingleThreadModel Interface an empty interface?

[482 byte] By [ylttana] at [2007-9-27 8:19:05]
# 1

SingleThreadModel is a marker interface (Serializable is another example) with no methods. The servlet engine checks whether a servlet implements the interface and then processes accordingly.

The API provides a good explanation:

If a servlet implements this interface, you are guaranteed that no two threads will execute concurrently in the servlet's service method. The servlet container can make this guarantee by synchronizing access to a single instance of the servlet, or by maintaining a pool of servlet instances and dispatching each new request to a free servlet.

This interface does not prevent synchronization problems that result from servlets accessing shared resources such as static class variables or classes outside the scope of the servlet.

GrayMana at 2007-7-8 16:04:35 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...