Implementing the Runnable Interface
Run method in sub-overlay interface
Thread is created through the thread class and the subclass object that implements the Runnable interface is passed as a parameter to thread
Constructors for classes
The thread class object calls the Start method to open threads
The thread starts with the Start method
Causes of security problems
Multiple threads are now delayed
Thread Randomness
The thread safety problem is not easy to appear in the ideal state, but once the impact on the software is very large.
Synchroized (object)
{
}
Synchronization can solve security problems, it is on the object
The premise of synchronization is multiple objects, and multiple threads use the same lock, consuming resources, synchronizing the concurrency after the cancellation, synchronization of the code as short as possible, inefficient.
A synchronous function is a function defined in a class that contains a synchronous object, or a class descriptor if it is static
The communication between threads is mainly a synchronization problem.
The problem of producers and consumers.
Any object has the function of the information light. The method called by any object must be defined in object. Waite can add wait until waiting queue, give up the monitoring power of the CPU, be notified by others, continue to seize the right to monitor. Sleep does not give up monitoring power to the CPU.
Synchronous methods need to add synchnoized
The priority of the thread is 10, and the priority can continue from the main thread
Java Foundation Nineth Day Course Summary