20165208 2017-2018-2 "Java program design" Eighth Week study summary textbook Learning content Summary Chapter 12th thread State
- To create a thread object
- Created directly with the thread class or subclass:
Thread(Runnable target)
creates a thread, gets the current thread object, and getName()
returns the name of the thread.
- Use the Runnable interface: more flexible than thread
- Run
run()
Method stipulates specific mission
- Interrupt
- Death
Common Methods of threading
start()
: Starts the thread, only the newly created thread can call the
run()
: Defines the actions that are performed after the thread object is dispatched, a method that the user must not refer to when the system is called automatically, and a subclass of the thread class overrides the original method.
sleep(int millsecond)
: Causes high priority to automatically discard CPU resources
isAlive()
: New and dead State return False,run () Start run until end call returns True
currentThread()
: Returns the thread that is using the CPU
interrupt()
: Restart the dormant thread
Thread synchronization
synchronized
Modified method, the synchronization mechanism should be followed when calling
Thread Federation
join().B
Causes a union B, that is, a thread to break execution until B completes
GUI thread
GUI: Graphical user interface
Mainly involves awt-eventquecue (responsible for handling GUI events) and Awt-windows (responsible for drawing the form or component to the desktop)
Timer thread
Timer(int a,Object b)
Create timer, Timer class start()
start thread, stop()
stop, restart restart()
recovery thread
Problems in teaching materials learning and the solving process
Issue one: p366 mentions that the runnable analogy thread subclass is more flexible when creating threads, but is not very understanding how runnable classes are used.
Workaround one: By accessing the data on the Internet, learn that the class that implements the Runnable interface must use an instance of the thread class to create a thread. Creating a thread from the Runnable interface is two steps:
- Instantiate the class that implements the Runnable interface.
- Establishes a thread object and passes the first instantiated object as a parameter to the constructor of the thread class.
Code Hosting
Last week's summary of the wrong quiz
- The following options are not the basic characteristics of a relational database.
A. Different columns should have different data types
B. Different columns should have different column names
C. Not related to the order of the lines
D. Not related to the order of the columns
The correct answer is a, which is not part of the basic characteristics of a relational database
- The following data manipulation languages are
A.insert
B.update
C.create
D.select
This is titled multiple selection, except for update, insert is also a data manipulation language
Other (sentiment, thinking, etc., optional)
This chapter mainly studies threading, multithreading as one of the characteristics of Java, but does not mean that multiple events are processed at the same time, and the knowledge of this chapter is more closely related to specific problems, can be used to better express and solve practical problems.
Resources
- "Java2 Practical Course (Fifth Edition)" Learning Guide
Learning progress Bar
|
lines of code (new/cumulative) |
Blog Volume (Add/accumulate) |
Learning Time (new/cumulative) |
Important Growth |
Goal |
5000 rows |
30 Articles |
400 hours |
|
First week |
36/36 |
4/4 |
30/30 |
|
Second week |
464/500 |
1/5 |
18/48 |
|
Third week |
832/1332 |
2/7 |
07n65 |
|
Week Four |
939/2271 |
2/9 |
07n65 |
|
Week Five |
1163/3434 |
1/10 |
07n65 |
|
Week Six |
1176/4610 |
1/11 |
15/65 |
|
Seventh Week |
864/5474 |
2/12 |
15/80 |
|
Eighth Week |
703/6177 |
2/14 |
15/80 |
|
20165208 2017-2018-2 "Java Programming" Eighth Week study summary