201621123030 Java programming 11th Week of study summary

Source: Internet
Author: User

1. Summary of this week's study

1.1 Summarize multithreading related content in the way you like (mind map or other).

2. Written work

This PTA work problem set多线程

1. Source code reading: Multi-threaded Bouncethread

What is the use of the 1.1 ballrunnable class? Why do I need calls Thread.sleep to hibernate in my code?

    • Ballrunnable implements the Runnable interface
    • Thread.Sleep can let this thread sleep for a while and leave the opportunity to other threads

1.2 Ball.java only do two things, what are the two things respectively? What does the Ballcomponent object do? What is the use of the ArrayList inside? How many ballcomponent objects are generated during the program run? The program uses multithreading techniques, each of which is drawn in separate threads?

    • Getshape () can generate 15x15 's ball position in (0,0), using Move () to get the position of the ball

    • Add the ball and draw it out

    • A Ballcomponent object was generated

    • Yes, every start time, a new thread is generated.

2. Experiment Summary: Problem sets (multithreading)

2.1 Topics: Thread, Printtask, runnable, and anonymous inner classes.
and answer: A) Runnable what is the benefit of implementing multithreaded programs by defining an implementation class for the interface, rather than implementing a multi-threaded program by inheriting from a Thread class? b) 6-1,6-3,6-11 experimental summary.

    • A) A class can inherit only one parent class, but can implement multiple interfaces.

    • b) Experimental Summary

      6-1 thread is to write a Mythread class to inherit the Thread, define an n, and output an integer from 1 to n-1

      6-3 runnable and anonymous inner class follow the steps to output it.

      6-11 printtask If you use print in the run () infinite loop, you can complete the flag false to true conversion

2.2 Using a lambda expression to overwrite 6-3

2.3 Title: 6-2 (runnable and stop thread). Answer: How do I need to properly stop a running thread?

To write public void stopMe(); to terminate a thread

3. Mutually exclusive access

3.1 Modify the Testunsynchronizedthread.java source code so that it can be accessed synchronously. (Key code, need to appear number)

4. Mutually exclusive access and synchronous access

Complete episode 6-4 (mutually exclusive access) with 6-5 (synchronous access)

4.1 In addition to using the synchronized modification method to achieve mutually exclusive synchronous access, what else can use synchronized to achieve mutually exclusive synchronous access, using code description (please show the relevant code and number)?

 

Use a re-entry lock (be sure to release the lock in time)

4.2 What is the difference between a synchronous code block and a synchronization method?

4.3 What is the principle of implementing mutually exclusive access? Use the object lock concept and describe it in conjunction with the corresponding code block. How does the state of the thread change when the program executes the synchronized synchronous code block or synchronous method?

4.4 What keywords are used in Java Multi-threading to implement communication between threads, so that threads work together?

3. Code Cloud and PTA

Topic Set:多线程

3.1. Code Cloud codes Submission record
    • In the Code cloud Project, select statistics-commits history-set time period, and then search for and

    • Several elements must appear: Submit Date-user name (name and school number)-No instructions

3.2 "Multi-threaded" PTA Submission List

Two graphs are required (1. Ranking chart. 2.PTA Submission list diagram)

3.3 Count the amount of code completed this week

The weekly code statistics need to be fused into a single table.

Week Time Total code Amount New Code Volume total number of files number of new files
2 330 330 5 5
3 625 322 11 6
4 1047 442 16 5
6 1978 425 21st 5
7 2643 40W 27 6
8 3341 798 39 8
9 4003 36W 49 10
10 4556 553 60 11
11 5219 36V 65 5

201621123030 Java programming 11th Week of 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.