Java dynamic proxy example

Dynamic proxy is commonly used in popular java frameworks, such as Spring, MyBatis and so on. There are other ways to implement proxy by using aspect or javassit and so on third part frameworks. In this page I will show you JDK dynamic proxy.

Chrome ERR_BLOCKED_BY_XSS_AUDITOR solution

When I POST some xml data to server by using chrome I got the error message like following.

Java Thread state example

There are 6 states for Java Thread. From JDK comment it says that A thread can be in only one state at a given point in time. In this page I will show you different states in thread life cycle. Hope the sample code can help you understand the states better.

Java template method pattern example

Template method pattern is commonly used in this scenario that main logic is stable but sub steps are not. Let's say you want to add export function in your system. For different data source there are different way to export data, but the main steps are the same: "getData", "processData" and "export". Let's try to use template method pattern in this example.

Linux mint add IDEA in applications menu

After downloading and unzipping the tar.gz file of IDEA I can start it by executing idea.sh. But I want to add it in Linux mint applications menu. For Linux mint the applications menu info is in / usr / share / applications /. Creating the file idea.desktop in this directory. The content is like following.

Linux mint make Chinese fonts clear

I have an old laptop with 4G memory and T6600 CPU. It installed Windows7 before and it runs slower and slower recently. I decide to install linux on it. Finally I choose Linux mint with xfce. It is not very beautiful but it's lightweight and use less memory. For the default Chinese fonts is not very clear. After google I use following command to make the fonts become clearer.

git show remote url

There are two ways to show remote repository in git.

guava cache example

Cache is very important for the project. Redis or MemoryCache are good choose for distribution project. If you want use local cache for your project guava is a good choose. I will show you how to use guava cache in this page.

Java bitwise example

Java provides several bitwise operators: &, |, ^ and ~. This page shows you how to use them.

Java state pattern example

State Pattern is for the scenario which contains different states. Let's consider the state of Amazon orders. When you want buy goods from Amazon the logic flow is: create order -> pay -> send goods -> receive goods -> evaluate. The status of order is changed after every operation and the action of order is changed correspondingly. The example code is like following.

Java find nth Fibonacci number example

There are two ways to find nth Fibonacci number: recursion and loop. Recursion is easy to write but is inefficient. Loop is not easy to write but efficient.

Java initializing fields order

If you can not make sure the execution order of block, static-block and constructor. This blog will write a demo to help you understand the order of initializing fields.

Java algorithm tutorial

This series of blog describes common algorithms.

Java reversing single linked list

In this page I will show you how to reverse single linked list in loop. Before starting write logic we need defined Node class.

Linux find which Java thread consuming cpu

Sometimes Java process used 100% or 200% CPU. It depends on the core number of your CPU. If your CPU has 8 cores that means the highest usage of a process is 800%. When Java process consuming most CPU you can use the following steps to find which Java threads is consuming the most CPU.