20165208 2017-2018-2 "Java Programming" Eighth Week study summary

Source: Internet
Author: User
Tags thread class

20165208 2017-2018-2 "Java program design" Eighth Week study summary textbook Learning content Summary Chapter 12th thread State
    • To create a thread object
    1. 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.
    2. 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

synchronizedModified method, the synchronization mechanism should be followed when calling

Thread Federation

join().BCauses 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:

    1. Instantiate the class that implements the Runnable interface.
    2. 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
    1. 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
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.