20165217 2017-2018-2 "Java Program Design" 8th Week study summary Textbook study summary
- Process-to-thread relationships
- Multi-threaded operation mechanism
- Four states of a thread: new, running, Interrupted, dead
- Use the thread class or subclass to create the characteristics of a threading object
- Common Methods for threading:
The start () thread calls the method to start the thread;
Run () defines the operations that are performed after the thread object is dispatched;
Sleep (int millsecond) causes high-priority threads to discard CPU resources and hibernate for a period of time. The sleep method must be called in the Try-catch statement block;
When the isAlive () thread is in the new state, the thread calls the IsAlive () method to return false. The thread calls the IsAlive () method to return True before the run () method of the threads ends, that is, before the death state is entered. When the thread enters the dead state, the thread calls the method IsAlive (), at which time the return value is false.
Daemon Thread: The thread defaults to a non-daemon thread, and the thread must set itself as a daemon before running. You can call Voidsetdaemon (Boolean on) to set yourself as a daemon thread. When all non-daemon threads run at the end, the daemon thread must end.
Problems in teaching materials learning and the solving process
Question 1: What is a time slice?
Problem 1 Solution: Through Baidu query, the time slice that the CPU allocates to each program time, each thread is allocated a time period, is called its time slice, namely this process allows the time to run, makes each program on the surface is simultaneously carries on.
Code Hosting
Last week's summary of the wrong quiz
- Error 1: The following data manipulation languages are: A.insert and b.update
Cause: Unclear understanding of the data manipulation language. Select is also selected as the data manipulation language.
Understand the situation: have mastered the basic content of the data manipulation language.
- Wrong question 2 and understanding: Statement's Executeupdate () method returns whether the successful int value is updated.
20165217 2017-2018-2 "Java Programming" 8th Week study Summary