How threads are Created
--------------------------------------
1. Inherit the Thread class.
2. Implement the Runnable interface.
1), create a thread through the thread class, and pass the class object that implements the Runnable interface as a parameter to the constructor of the thread class. The thread class called the start () method to start the thread.
3. The thread calls the Start method and does not execute immediately, but is in a ready state, waiting for the CPU to execute.
4. Thread security issues.
Thread synchronization
------------------------------------------------
1. Thread synchronization: Synchronized (object) {.. Code blocks that need to be synchronized ...}. The object here is an object of any class. The object is like the function of a lock.
2. Prerequisites for Thread synchronization:
1) synchronization requires two or more threads.
2) Multiple threads using the same lock
3. Synchronization will reduce the efficiency of the program operation. So the code in sync is as short as possible.
4. The synchronization method uses the lock of the object on which the method resides.
Thread Wait (wait)
--------------------------------------
1. After the thread calls wait, the thread frees the CPU and waits, and after the CPU is acquired again, the code executes from wait.
Priority of the thread
---------------------------
1.setPriority (); Set the priority of a thread
2.getPriority (); Gets the priority of the thread
3. High-priority CPU gain is a bit more likely.
Thread state transition diagram
------------------------------------------------
650) this.width=650; "src=" http://note.youdao.com/yws/res/211/502D74341A9E4DD69C0813D76A3A6924 "style=" margin-top : 8px;height:566.737px;width:800px; "alt=" 502d74341a9e4dd69c0813d76a3a6924 "/>
Strng
---------------------------------------------------
1. "= =" is to determine whether the memory address of two string objects is equal
2. "Equal" is to determine whether the contents of two string objects are equal
3.StringBuffer is thread-safe. Low efficiency. StringBuilder is a class that is later added and is thread insecure and highly efficient.
4. Unpacking and boxing of basic data types.
Big Data-java Foundation -9day