Java CyclicBarrier example

CyclicBarrier is a tool class in concurrent package. It is used to make the thread waiting for other threads. All threads will be waked up when they are all in "wait" state. The sample code is here.

Relational Database tutorial

Common operations for relational database(MySQL & PostgreSQL).

MySQL delete duplicate rows

Duplicate rows will be in you table when you don't use unique key for some reason. In this page I will show you how to remove duplicate rows in MySQL. Let's say the schema of user table is like following.

Linux chkconfig example

chkconfig command can help you check or update the services installed in your environment. Let's say you have installed postgreSQL in your Linux. The script named "postgresql" will be installed in the directory "/etc/init.d/". chkconfig or chkconfig --list will output the services status like following.

Java CountDownLatch example

In java, if you want do something after multiple threads finish CountDownLatch might help you. This class can help you count how many threads is finished. If there is no thread running, it will wake up the main thread. The code example is like following.

How ArrayList increase

As we all know ArrayList use array to store the items. The length of array is fixed. When the array can't hold all items it will increase. I want to know how ArrayList increases the length. I found the source code(JDK1.8) like following.

Java execute command example

Sometimes we need to execute commands in Java. I will show you how to do it in this blog. The code is like following. I assume you use Windows and have installed JDK in your environment. If you use Linux or Mac call runtime.exec("java") will execute java command.

MyBatis show sql log example

Show sql log can help you know the detail of your sql when you use MyBatis. I will show you how to show the sql log when you use MyBatis. The content of pom.xml is like following.

Java heap dump example

We use jmap command to dump the Java heap. Examples are here.

CentOS show version number

In CentOS, run the following command will get the version number.

Java ReentrantLock example

ReentrantLock and synchronized keyword both can make sure only one thread execute the code on the same time. They are similar but not the same. ReentrantLock is more flexible than synchronized. In this page I will show you a simple use case of ReentrantLock.

Linux scp command examples

scp command can help you copy file from remote computer. Here are some examples.

Linux awk command examples

awk is more power than grep when you want handle the text in Linux. awk read the input line by line and split the words by space. You can also define your own separator.

git merge rebase

There are two ways to put your change to remote: merge and rebase. Let's say there is a branch and you develop your feature in this branch. You merge the changes to this branch you will get the result like following.

Git create remote branch

You can use these commands to create a new branch locally and push it to remote.