20165235 Qi Ying 2018-4 "Java Programming" eighth week study summary

20165235 Qi Ying 2018-4 "Java Programming" eighth week study summary

Textbook learning content summary

Operating Systems and Processes
  • A program is a static piece of code that is the blueprint for application software execution. A process is a dynamic execution process of a program, which corresponds to a complete process from code loading, execution to execution completion. This process is also the process itself from generation to development to death.

    process and thread
  • Certain memory units in a process can be shared between threads.

    java multithreading mechanism
  • The Java virtual machine quickly switches control from one thread to another, and these threads will be executed in turn, giving each thread a chance to use CPU resources.

    main thread
  • mainThreads are primarily responsible for executing mainmethods. The threads that are created during mainthe execution of the method are called other threads in the program.
  • JVMIt is necessary to alternate between the main thread and other threads to ensure that each thread has a chance to use CPUresources.

    Thread state and life cycle
  • javaThe language uses Threadobjects of classes and their subclasses to represent threads.
    - start()The method notifies the JVM, and the JVM will know that a new thread is queued.
  • sleep(int millsecond)method to put the current thread to sleep.
    - run ()The method specifies the specific mission of the thread.

    Thread class
  • One way to create a thread is to use the Threadclass to create the thread object directly. Usually its constructor is used.
  • Using Runnableinterfaces is Threadmore flexible than using subclasses.

    The relationship between the target object and the thread object
  • The target object is completely decoupled from the thread object
  • target object composition thread

    thread synchronization
  • Several threads use a synchronizeddecorated method. Multiple threads calling synchronizedthe decorated method must obey the synchronization mechanism.

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

Problems and Solving Processes in Teaching Materials Learning

  • Question 1: When running Example12_3, the results of each run are inconsistent?

  • Solution: This problem has not been solved yet, but I personally think that Threadthe two threads of cat and dog are randomly alternated when using CPU resources. It is uncertain who gets the resources first, so there will be inconsistent results.

Code cloud code link

Summary of last week's exam mistakes

  1. The ones that belong to the data manipulation language are: insert and update
  2. Statement's executeUpdate() method returns an int value
  3. The correct exception is: java.sql.SQLException: result set is exhausted (result set is exhausted or next is not called); java.sql.SQLException: No suitable driver (URL misspelled)
  4. Which of the following are the methods defined in the ResultSet for Cursor positioning:
  • next()
  • beforeFirst()
  • afterLast()
  • isBeforeFirst()
  • relative(int)

    comprehension

  • Through this week's study, we have some understanding of threads. When allocating CPU resources to threads, we can understand transitions between different states.

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 31/31 1/1 20/20 use of git
the second week 373/404 2/3 18/38 java basic data syntax
The third week 547/920 1/4 22/60 Classes and objects and packaging
the fourth week 919/1839 2/6 30/80 Subclassing and Inheritance, Interfaces and Interface-Oriented Programming
fifth week 500/2300 3/9 20/ 100 Input and output streams and inner classes
Week 6 300/2600 1/10 25/125 Generics and collections framework, common utility classes
Week 7 447/3047 3/13 25/150 MySQL database and JDBC
eighth week 700/3826 3/16 25/175 java multithreading mechanism

References

Guess you like

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