After learning this chapter, the reader needs to answer:

1. What is a thread? What is a process?

2. What are the states of threads?

3. What is thread safety?

What is a thread? What is a process?

Thread is the smallest unit that the operating system can schedule operations. It is contained in the process and is the actual operating unit in the process. See Figure 6.2. For example, our commonly used QQ, computer housekeeper and so on are independent process.

Figure 6.2 process

The programs you see running separately are a separate process, and the processes are independent of each other.

What states do threads have?

In Java, threads typically have five states: created, ready, running, blocked, and dead.