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.
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.
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.
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.
We use jmap command to dump the Java heap. Examples are here.
In CentOS, run the following command will get the version number.
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.
scp command can help you copy file from remote computer. Here are some 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.
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.
You can use these commands to create a new branch locally and push it to remote.
When I try to dump the table with the mysqldump command I got the error message. The dump command and the error message are here.
Before Java8 if you need convert list to map you have to iterate over the list. Java8 provide stream to help you iterate over the list. You can convert list to map by using stream with only one line of code.
Spring Data KeyValue framework use java.util.Map to store data in memory. I will show you how use it in this page.
The isAssignableFrom method is used to judge the relationship of two classes. This method can tell you whether A is the subclass of B. or A class implement B interface. The example code is here.