Detailed resolution of related methods for Java threads

  • 2020-04-01 02:18:05
  • OfStack

Start ()   Start thread method

The run ()   When the start () method is called, the method body of that method is actually executed

Sleep ()   Put the current thread to sleep and the sleep will automatically wake up and enter the runnable state instead of the runnable state

Yield () suspends the currently executing Thread object, the JVM Thread scheduler invokes other threads of high priority based on the preemptive mechanism of priority, the priority ranges from 1 (thread.min_priority) to 10(thread.max_priority), and the default value of the created Thread is 5 (NORM_PRIORITY).

SetPriority (int newPriority)   Set a new priority for the thread

The join ()   Wait for the thread to terminate before executing the current thread; For example, the join() method of thread B is called in thread A, and the execution of thread A will not continue until the execution of thread B is terminated. When the execution of thread B is terminated, thread A will enter the runnable state.


Related articles: