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

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

File Change Notification with Watch Service API

Since Java 7, the java.nio.file package adds a feature: file change notification with Watch Service API – java.nio.file.WatchService. Watch Service API allows us to register directories with the watch service, and monitor the directories and files for any changes including creation, deletion, modification etc. The post will briefly introduce the usage of Watch Service API. Continue reading