11th Chapter? If you want to design the process independently of main (), you can compose a class operation Java.lang.Runnable interface, and the entry point of the process is the operation in the run () method. If you want to add the main thread, create a thread instance, and to start the additional main thread is to invoke The start () method of the thread instance. The main thread executes from the main () method until the main () method ends and the JVM is stalled. If additional threads are started in the main thread, the default is to wait for all threads that are started to execute the run () method before terminating the JVM. If a THEAD is represented as a daemon thread, the JVM automatically terminates at the end of all non-daemon threads. Thread basic state diagram: High priority is performed first, otherwise the flow is executed. Start-->runnable--> (blocked)-->running-->dead? Placement thread: When a thread joins to another thread using join (), another thread waits for the joined thread to finish working, Then in the continuation of its action, the join () means that the thread is joined in the process called another thread.? Stop thread: After the thread finishes the run () method, it enters dead, and the thread entering dead cannot call the start () method again. Otherwise, a Illegalthreadstateexception exception is thrown.
Import Java.util.Arrays;
? Copyonwritearrayset operation of the list interface, when an instance of this class is written, a new array is created internally, the reference to the original array index is copied, and a write operation is made on the new array, and after the write is completed, the variables referencing the old array inside the original reference to the new array are referenced. Code managed code
Study summary? When learning, incorrect use of synchronized will appear "knot"? To avoid locking the lock object after it throws an exception in the subsequent execution process, it is important to call the unlock method of the lock object in finally.
20165305 Suzhenrong "Java program Design" seventh weeks of testing and repair