20165326 Java Eighth Week study notes

Source: Internet
Author: User

Summary of the eighth week study notes knowledge points

1. Process and Thread

    • Process: A dynamic execution of a program
    • Difference: The difference between a process and a thread?
    • A process is a separate unit of resource allocation and scheduling, while a thread is the basic unit of CPU scheduling
    • The same process can include multiple threads, and the thread shares the resources (registers, stacks, contexts) of the entire process, one for at least one thread.
    • The multithreading mechanism of Java. Java has built-in support for multithreading. Our computer can only execute one of the threads at any given point in time, and the Java Virtual machine simply switches from one thread to another.
      When there are other threads in the main method, the JVM waits until all the threads in the Java application end before the Java application ends.

2. There are three ways to create threads:

    • Inherit the thread class to create threads, you can use the method if you want to get the current thread object, or you Thread.currentThread() can use the method if you want to return the name of the thread:getName()
    • Implementing an Runnable interface creation thread
    • Using Callable and Future creating threads

3. Thread synchronization: If there are several threads that need to use a single method at the same time, you can use synchronized to decorate them in order to avoid confusion. In this way, the method can only be called in turn until the thread that is calling the method finishes using the method, and other threads can call the method.

4, Thread union: Thread A during its run, if other thread B calls the join () method and thread A union, then the a line routines immediately interrupts, until the B thread runs end a thread will not be re-queued. If the B thread has ended, calling the join () method will have no effect.

5. Daemon Thread: The thread defaults to a non-daemon thread, and the thread must set itself as the daemon thread 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.

Code Hosting

Code Cloud Link

Last week's topic summary

1. Typical JDBC Programming sequence: Register JDBC driver→ to get physical connection to database → create different types of statement→ Execute SQL commands → If there is a result set, process the result set → release the resource

2. The statement executeupdate () method returns whether the successful int value is updated

3, Java.sql provides Java access to database capabilities of the package

4, relational database features:

    • Consistent data types in the same column, different data types must be defined with different columns
    • Different columns without sequential differences
    • Any two tuples cannot be identical.
    • No peers, no sequential differences.

20165326 Java Eighth Week study notes

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.