20165215 2017-2018-2 "Java Programming" Week 8 Learning Summary
Textbook learning content summary
- process and thread
- A process is a dynamic execution process of a program, which corresponds to a complete process from code loading, execution to execution completion.
- A thread is a smaller unit of execution than a process
- Process in Java
- A computer can only execute one of those threads at any given moment
- The Java language uses
Thread
objects of classes and their subclasses to represent threads - After the thread is created, it only occupies memory resources, and the start() method must be called to notify the JVM
- The program must override the run() method of the parent class in the child class
- The sleep(int millsecond) method puts the current thread into a sleep state, and the wait() method makes the current thread enter a waiting state
- The so-called dead state is that the thread releases the entity, that is, releases the memory allocated to the thread object
- Thread class and thread creation
- The construction method usually used to create a thread using Thread is Thread (Runnable target)
- When the target object is completely decoupled from the thread, the target object needs to obtain the name of the thread to determine which thread is occupying the CPU; in the target object combined thread, the target object can obtain a reference to the thread object
- Common method
- start();
- run(), before the thread ends run(), do not let the thread call the start() method, otherwise an IllegalThreadStateException will occur
- sleep(int millsecond) must call the sleep method in a try-catch block
- isAlive();
- currentThread() returns the thread that is currently using CPU resources
- interrupt();
- Thread synchronization mechanism: when a thread A uses the synchronized method, it must wait until thread A finishes using the synchronized method
- You cannot use wait(), notify(), notifyAll() in unsynchronized methods
- A uses Join() to join B during operation, then the A thread immediately executes the terminal, and waits for the execution of B to end, and A re-queues to wait for CPU resources
- The AWT-EventQueue thread is responsible for handling GUI events, and the AWT-Windows thread is responsible for drawing forms or components to the desktop
Problems and solutions in code debugging
- Question 1: The following error occurs when compiling example 1
- Problem 1 solution: add
encoding
parameter: javac -encoding gbk Example12_1.java, then run successfully
code hosting
(screenshot of the running result of the statistics.sh script)
Summary of last week's exam mistakes
- wrong question 1
- Understanding the situation: Xammp is a powerful website integration software package in which databases can be created
- wrong question 2
- Understanding: Data manipulation language refers to querying, inserting, deleting, and modifying data in tables
- wrong question 3
- Understanding the situation: java.sql.SQLException: Unknown column 'sid' in 'field list' means that there is an unknown column "SID" in the "field list"
learning progress bar
Lines of code (added/accumulated) | Blog volume (new/cumulative) | Study time (added/accumulated) | important growth | |
---|---|---|---|---|
Target | 5000 lines | 30 articles | 400 hours | |
the first week | 37/37 | 1/1 | 15/15 | |
the second week | 398/429 | 2/3 | 15/30 | |
The third week | 753/1167 | 1/4 | 20/50 | |
the fourth week | 1296/2109 | 2/6 | 20/70 | |
fifth week | 1191/3323 | 2/8 | 20/90 | |
Week 6 | 1806/4390 | 2/10 | 15/105 | |
Week 7 | 1260/5145 | 2/12 | 15/120 | |
eighth week | 606/5745 | 3/15 | 20/140 |