20165305 Suzhenrong "Java program Design" seventh weeks of testing and repair

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.