How to Optimize Tomcat Performance

The default Tomcat configuration looks powerful and hassle-free to the 1st time users. However, it is not customized for the real work where high server load can be expected. Therefore, it is important to optimize Tomcat performance by setting customization and system tuning.

The post will describe how to optimize Tomcat performance. Continue reading

Difference between flush and commit in Hibernate

Session flush is the process of synchronizing the underlying persistent store with persistable state held in memory. Flushing the session simply gets the data in the session synchronized with the database. If a persisted object in the Session has value change, it becomes dirty, and Session flush will update the database in the running transaction, but it may not commit those changes. Continue reading

When and How to Use ThreadLocal in Java

What is ThreadLocal?

In Java, ThreadLocal has been used since JDK 1.2. In multi-threaded programming, there are multiple ways to achieve thread safety via synchronization / locks. ThreadLocal is a different way to achieve thread-safety by providing explicitly a copy of Object to each thread. Since the Object is not shared, there is no requirement of Synchronization. Therefore, it will help the application performance & system scalability improvement. Continue reading

Strategy Pattern

The intent of Strategy pattern is to define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets a class behavior or its algorithm can be changed at run time. It captures the abstraction in an interface, and provides implementation details in derived classes. Continue reading