20165236 2017-2018-2 "Java Programming" Eighth Week study summary
The 12th chapter summarizes the contents of the textbook:
1, the multithreading mechanism of Java;
Multithreading is the case where there are several actuators in an application that work together in several different execution threads, which makes it easy for programmers to develop powerful applications that have multi-threaded capabilities that can handle multiple tasks at the same time.
Main threads (main thread):
When the JVM loads the code and discovers the Main method, it starts a thread, which is the "main thread".
2, the state of the thread and the life cycle
New, running, interrupted, dead;
3, thread class and the creation of threads
Thread creation: Thread objects are created with subclasses of thread, and thread objects are created directly using the thread class;
The relationship between the target object and the thread;
About the number of times the run method was started;
4. Common methods of threading
Start (): Invokes the method to start the thread;
Run (): Defines the operations that are performed after the thread object is dispatched;
Sleep (int millsecond), isAlive (), CurrentThread (), interrupt;
5. Thread Synchronization
That is, several threads in a program need to use a method, which is decorated with synchronized.
6. Coordinating Threads for synchronization
The Wait () method interrupts the execution of the method, causes the thread to wait, temporarily yields the CPU, and allows other threads to use the synchronization method.
The Notifyall () method notifies all waiting threads that are waiting by using this synchronization method. The thread that was interrupted will continue to execute this synchronization method from the point where it was just interrupted, and follow the principle of "first break first".
The Notify () method simply notifies a waiting thread of the end of a wait.
7. Thread Federation
While a thread A is occupying CPU resources, it is possible for other threads to call join () and this thread union.
8. GUI Thread
When a Java program contains a graphical user interface (GUI), the Java virtual machine automatically launches more threads when the application is run, where the awt-eventquecue thread is responsible for handling GUI events, and the awt-windows thread is responsible for drawing the form or component to the desktop.
9. Timer thread
Second, the script running results:
Third, last week's summary of the wrong title
1, the following is the data operating language is (AB)A.insertb.updatec.created.select
2, the following options are not the basic characteristics of the relational database is (a)A. Different columns should have different data types B. Different columns should have different column names c. Independent of the Order of the rows D. Independent of the Order of the columns
3, the exception type of JDBC programming is divided into (AC)A.sqlexceptionb.sqlerrorc.sqlwarningd.sqlfatale.sqltruncation
Four, this week learning sentiment:
After a week of study, I also re-realized that Java learning is a gradual process, only to take each step of the good, do not give up any difficulty, can continue to learn java.
20165236 2017-2018-2 "Java Programming" Eighth Week study summary