First, the basic concept
- A program is a static code that is the blueprint for application execution.
- A process is a dynamic execution of a program that corresponds to a complete process from code loading to execution to completion.
- The operating system allocates a separate memory space and system resources for each process, including: code data and resources such as stacks. The internal data and state of each process are completely independent.
- In a multitasking operating system, process switching is expensive for CPU resources.
- Multithreading is a number of execution threads that occur during process execution.
- A thread is a smaller unit than a process execution.
- Threads cannot exist independently and must exist in the process, sharing process space data among the threads of the same process.
- Each thread has its own production, existence and extinction process, is a dynamic concept.
- Multithreading means that a multi-line statement of a program can appear to run at the same time almost simultaneously.
- Thread creation, destruction, and switching loads are much smaller than processes, also known as lightweight processes (lightweight process).
Second, the interruption of the thread
- When the thread's Run method executes the last statement in the method body and returns by executing a return statement, or if there is an exception that is not caught in the method, the thread terminates and yields the CPU usage.
- Calling the interrupt () method can also terminate the thread. The interrupt () method can break not only the running thread, but also the thread in the blocked state, at which point the interrupt () method throws a Interruptedexception exception.
- Java provides several methods for testing whether a thread has been interrupted.
Third, the state of the thread
- Through the state transformation of each thread, we can control each thread to take turns using CPU, and embody the parallelism characteristic of multithreading.
- There are 6 types of threads in the following states:
- New (newly created)
- Runnable (can be run)
- Blocked (blocked)
- Waiting (Wait)
- Timed Waiting (timed Wait)
- Terminated (terminated)
Four, object-oriented Programming curriculum learning progress bar
Moonphases |
Number of lines of code (read/write) |
Post Blog volume/Comment blog number |
Classroom/after-school time (hours) |
The most satisfying programming task |
First week |
20/7 |
1/1 |
6/4 |
Write the Hello World program |
Second week |
38/20 |
1/1 |
6/5 |
Experiment two task three |
Third week |
50/30 |
1/1 |
6/7 |
Experiment Three |
Week Four |
58/46 |
1/1 |
6/5 |
Write the output n digits of the numbers, and sum |
Week Five |
67/53 |
1/1 |
6/6 |
Classes are defined and overloaded |
Week Six |
71/60 |
1/1 |
6/4 |
Interface |
Eighth Week |
80/66 |
1/1 |
6/3 |
LAMDBA-expression |
Nineth Week |
85/60 |
1/1 |
6/2 |
Operation of the ID |
Tenth Week |
121/80 |
1/1 |
6/2 |
Experiment Nine |
11th Week |
120/84 |
1/1 |
6/2 |
Experiment Ten |
12th Week |
131/90 |
1/1 |
6/2 |
Experiment Xi. |
13th Week |
130/100 |
1/1 |
6/2 |
Experiment 12 |
14th Week |
120/90 |
1/1 |
6/2 |
Experiment 13 |
15th Week |
124/90 |
1/1 |
6/2 |
Experiment 14 |
16th Week |
130/80 |
1/1 |
6/2 |
Experiment 14 |
17th Week |
130/90 |
1/ |
6/2 |
Concurrent |
...... |
|
|
|
|
Cumulative |
1545/959 |
17/16 |
96/52 |
|
201671010128 the concurrency of Java programming in 2017-12-17