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