20165303 Eighth week study summary

  • Summary
    of knowledge points 1. Java's thread class and Runnable interface
    Thread class
    public Thread() creates a thread object; public Thread(Runnable target)
    target is called the target object of the created thread, which is responsible for implementing the Runnable
    thread priority . The
    Thread class has three related threads Static constants for priority: MIN_PRIORITY, MAX_PRIORITY, NORM_PRIORITY

Main method
Start the thread start(); define the thread operation run()
to make the thread sleep sleep(): sleep(intmillsecond) sleep time in milliseconds
sleep(int millsecond,int nanosecond) sleep time in nanoseconds
currentThread( ) Thread to determine who is occupying the CPU
NEW: The thread that has not been started so far is in this state. Generally speaking, this state is the state where the start() method has never been executed after the thread is instantiated;
RUNNABLE: It is being executed in the java virtual machine A thread is in this state;
BLOCKED: A thread that is blocked and waiting for a monitor lock is in this state;
WAITING: A thread that waits indefinitely for another thread to perform a certain operation is in this state;
TIMED_WAITING: Waiting for another thread A thread to perform operations that depend on the specified wait time is in this state;
TERMINATED: An exited thread is in this state and the thread is destroyed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324684177&siteId=291194637