SCJP5 learning Notes 1. Concept of operating system midline and process the current operating system is a multi-task operating system. Multithreading is a way to implement multiple tasks. A process is an application running in the memory. Each process has its own memory space. A process can start multiple threads. For example, in Windows, a running exe is a process. A thread is an execution process in a process. A process can run multiple threads. For example, a java. EXE process can run multiple threads. A thread always belongs to a process. multiple threads in the process share the memory of the process. "At the same time" execution is a human perception, and is actually rotated between threads. 2. in Java, "Threads" refer to two different things: 1. an instance of the Java. lang. Thread class; 2. Thread execution. Use the java. lang. Thread class or java. lang. Runnable interface to write code to define, instantiate, and start a new Thread. A Thread class instance is just an object. Like any other object in Java, it has variables and methods, and is born and died on the heap. In Java, each thread has a call stack. Even if no new thread is created in the program, the thread runs in the background. A Java application always runs from the main () method, and the mian () method runs in a thread, which is called the main thread. Once a new thread is created, a new call stack is generated. Threads are divided into two types: User thread and waiting thread. When all user threads are executed, the JVM automatically closes. However, the waiting thread is not independent from the JVM. The waiting thread is generally created by the operating system or the user.