201671010116.2016-2017-17 "Java Programming" 17th Week study Summary

Source: Internet
Author: User

This week, through self-study and under the leadership of teachers to learn the thread. The main points of knowledge are as follows:

1. Multithreading is a number of execution threads that occur during process execution. Multithreading means that a multi-line statement of a program can appear to run at the same time almost simultaneously.
2. Threads are smaller units than process execution.
3. Threads cannot exist independently and must exist in the process, sharing process space data between threads of the same process.

There are two ways to implement multithreading in 4.java:

(1). Create a subclass of thread

(2). Define the interface that implements runnable in the program

5. Advantages of implementing the Runnable interface:

(1). Conform to OO design ideas

(2). Easy to use extends inheriting other classes

6. Threads can have a status of 7:

New (new), Runnable (operational), Running (Run), Blocked (blocked), Waiting (wait), time waiting (timed wait), Terminated (aborted).

To determine the current state of a thread, you can call the GetState method.

In the second question of this week's programming exercise, the randomness of the program's running results is adjusted by changing the response time of sleep.

201671010116.2016-2017-17 "Java Programming" 17th Week study Summary

Related Article

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.