Sunday, December 2, 2007

JSP - Synchronization

By default JSP pages are Multithreaded(Multi-thread model), ie they are not synchronized.

Normally if we need to make a class synchronized, we implement SingleThreadModel interface.

In JSP, if that page has to be synchronized, we should add

<%@page isThreadSafe="false"%>

Or,

If some code inside the JSP page has to be synchronized, then the Implicit object "page" can be made use of.

<%
synchronized(page)
{
//code that needs to be synchronized
}
%>

Different Names, But same concept

Factory Methods

Factory method is just a fancy name for a method that instantiates objects.

Ex: In Singleton Design Pattern, we use a static synchronized method for instantiating object of that Singleton class.


Marker Interface or Tagged Interface

Interface without data-members and methods are called Marker Interface or Tagged Interface.

Ex: Serializable Interface