Performance Bottleneck

Introducing the synchronized block/method performs slightly slower than the normal and causes performance bottleneck. In the object instantiation time, we need to make sure that not more than one object get instantiated. Afterwards, any number of threads can possibly access with zero delay. While introducing the synchronized block/method, some delay may occur.

To overcome this delay, we may need to introduce the null-if check before obtaining the monitoring-lock.

LazyHolder Pattern

Before object initialization itself, we get more than 100 threads span and waits to obtain the lock on synchronized block, then the above sample also will not perform good.

As per Java Language Specification, in JVM, class load and initialization phase is serial. Utilizing this as an advantage, we can initialize the singleton object through some other class initialization phase. This approach works as on-demand(lazy loading) initialization object.

Monday, October 4, 2010

JAXB : DataTypeConverter

Accessing the actual value as-it-is using JAVA API will be pain in some cases. For instance, list of values get stored in attribute with comma separation. Now, these value has to be retrieved as List object rather String object, then only it make sense and simple to use.

We are extending the sample written in JAXB Sample post to explain DataTypeConverter and XMLAdapter.

jaxbexample.DataTypeConverter is a JAVA file and it has two methods parseStringToList, printListToString. In the time of generating JAXB beans, Adapter1.java is get created in jaxbexamples.model package.

Recent Posts

Texts

This blog intended to share the knowledge and contribute to JAVA Community such a way that by providing samples and pointing right documents/webpages. We try to give our knowledege level best and no guarantee can be claimed on truth. Copyright and Terms of Policy refer blogspot.com