20165217 2017-2018-2 "Java Programming" Week 8 Learning Summary

20165217 2017-2018-2 "Java Programming" Week 8 Learning Summary

Textbook learning content summary

  • Process and thread relationship
  • Multi-threaded operation mechanism
  • The four states of a thread: new, running, interrupted, and dead
  • Features of Creating Thread Objects Using the Thread Class or Subclasses
  • Common methods of threads:
    start() Thread calling this method will start the thread;

run() is used to define the operation performed after the thread object is scheduled;

sleep(int millsecond) Make the thread with high priority give up CPU resources and sleep for a period of time. The sleep method must be called in a try-catch block;

isAlive() When the thread is in the "new" state, the thread calls the isAlive() method and returns false. Before the thread's run() method ends, that is, before it enters the dead state, the thread calls the isAlive() method to return true. When the thread enters the dead state, the thread calls the method isAlive(), and the return value at this time is false.

  • Daemon thread: The thread is a non-daemon thread by default, and the thread must set whether it is a daemon thread before running. You can call voidsetDaemon(boolean on) to set yourself up as a daemon thread. When all non-daemon threads finish running, daemon threads must end with them.

    Problems and Solving Processes in Teaching Materials Learning

  • Question 1: What is a time slice?
    Solution to problem 1: Through Baidu query, the time slice is the time allocated by the CPU to each program, and each thread is assigned a time period, called its time slice, that is, the time the process is allowed to run, so that each program can appear on the surface. Seeing is happening at the same time.

code hosting

Summary of last week's exam mistakes

  • Wrong question 1: The following are data manipulation languages: A.insert and B.update
    Reason: I don't know the data manipulation language. Select is also selected as the data manipulation language.

Comprehension: Have mastered the basic content of data manipulation language.

  • Wrong question 2 and understanding: The executeUpdate() method of Statement will return the int value of whether the update is successful.

Guess you like

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