Java understand daemon thread

Recently I am writing a program that processes messages in the background. The program quits when I start 10 threads. I checked all the exception stack information and found no errors. I tried to find this "error" on Google and didn't find any useful information. Why my program or my thread stop? I read my code line by line. It seems like following.

MySQL change data directory

The default data directory of MySQL is /var/lib/mysql. If there is no disk space for this directory we need to move data to another directory(another fileSystem). In my environment I install MySQL by yum command. The /var/lib/mysql directory is mounted on / and there is no more space for data. I change data directory by using these following commands.

fastjson convert generic classes(list)

fastjson is excellent framework for handle json data. It can parse json string to generic classes. Here is sample code.

Linux telnet check remote port

We can use telnet to check weather the remote server port is open or not. The command is easy to use, just telnet . When the remote server port is open it will output like following.

Linux share directory with python

Sometimes we need copy file from server to local. There are several ways to do that. We can use scp, sz commands to transfer files. scp command need us to input local IP, username and password. sz command need us to install lrzsz. Today I found another way to do this.

Apache commons stopwatch example

The class StopWatch class which in apache-common-lang package is a good tool for timing. It provides some useful method to measured running time of program. Most of these methods of StopWatch are easy to understand. Only one method: split() need us try to understand.

Intellij column increase number

When I defined thrift file I need to create a column of numbers. The file looks something like this.

Java RSA encrypt decrypt example

In this page I will show you how to use RSA to encrypt and decrypt data. As we all know RSA is one of asymmetric cryptographic algorithm. We need generate public key and private key before encrypting and decrypting data. The sample code is here.

Jackson custom deserializer

We can use Jackson convert between json and object. But sometimes we need custom deserializer for special json. Let's say you need to handle the json like following.

Git tutorial

Git is a distributed revision-control system.

JMH example

Java Microbenchmark Harness is a good tool to test your code. It can tell you the code is efficiently or not. Today I will show you how to use it to test your code. Let's say you want to implement a functionality about probability. Maybe you want your program have a 1/10 probability of doing something. You have two ways to implement this.

Linux yum show installed packages

Let's say you have installed some packages in your Linux. The following commend help you show installed packages. Use yum and grep commends can help you find installed packages.

PostgreSQL display result vertically

In MySQL we can add \G in the end of sql to show the result vertically. In PostgreSQL you need to enter \x to show the result vertically. It is a toggle. Example sql is here.

Relative time in computer

In this book Systems Performance: Enterprise and the Cloud author make a single CPU cycle equivalent to one second to make us feel how fast CPU is.

Java8 parse string to LocalDateTime

SimpleDateFormat is the only choice when you want to parse String to Date before Java8. But, SimpleDateFormat is unthread-safe class. You may get the wrong result when you use it in multi-thread scenario. I recommend you use DateTimeFormatter to handle date string.