20165236 2017-2018-2 "Java Programming" Eighth Week Learning Summary

20165236 2017-2018-2 "Java Programming" Eighth Week Learning Summary

1. Summary of the content of the textbook in Chapter 12:

1. Java's multi-threading mechanism;

     Multi-threading refers to the situation where several execution bodies exist in an application at the same time, and work together according to several different execution threads. It allows programmers to easily develop functions with multi-threading functions and can handle multiple tasks at the same time. Powerful application.

     Main thread (main thread):

     When the JVM loads the code and finds the main method, it starts a thread, which is the "main thread".

2. Thread status and life cycle

     new, running, interrupted, dead;

3. Thread class and thread creation

      Thread creation: create a thread object with a subclass of Thread; create a thread object directly with the Thread class;

      The relationship between the target object and the thread;

      About the number of times the run method is started;

4. Common methods of threads

      start(): call this method to start the thread;

      run(): defines the operation performed after the thread object is scheduled;

      sleep(int millsecond)、isAlive()、currentThread()、interrupt;

5. Thread synchronization

      That is, several threads in the program need to use a method, which is decorated with synchronized.

6. Coordinate and synchronize threads

      The wait() method can interrupt the execution of the method, make the thread wait, temporarily give up the right to use the CPU, and allow other threads to use this synchronization method.

      The notifyAll() method notifies all threads that are waiting due to the use of this synchronization method to end waiting. The thread that has been interrupted will continue to execute this synchronization method from the point where it was interrupted just now, and follow the principle of "interrupt first, continue first".

      The notify() method just notifies one of the waiting threads that one of them has finished waiting.

7. Thread union

     While a thread A occupies CPU resources, it can let other threads call join() to join this thread.

8. GUI thread

      When a JAVA program contains a graphical user interface (GUI), the JAVA virtual machine will automatically start more threads when running the application. 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. .

9. Timer thread

2. Screenshot of script running result:

 3. Summary of last week's mistakes

1. Which of the following is a data manipulation language (AB)
 
A.insert
B.update
C.create
D.select

2. The following options are not the basic characteristics of relational databases are (A)
 
A. Different columns should have different data types
B. Different columns should have different column names
C. has nothing to do with the order of the lines
D. has nothing to do with the order of the columns

3. The exception types of JDBC programming are divided into (AC)
 
A.SQLException
B.SQLError
C.SQLWarning
D.SQLFatal
E.SQLTruncation

Fourth, this week's learning insights:

After another week of study, I once again realized that Java learning is a step-by-step process. Only by taking each step well and not giving up any difficulties can I continue to learn Java well.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324620776&siteId=291194637