Multi-Threaded---priority &yield method

Source: Internet
Author: User

The priority level is only 10 levels, 1-10. Max (with thread.max_priority in Java), minimum 1, intermediate level 5.

The method to set the priority is the thread object. SetPriority (5);

Yield:

pauses (not stops) the currently executing thread and executes other threads.


PS: The data is fixed with the constant final, and the data is shared statically.

Anonymous internal classes are used by threads:

Anonymous inner class of the inheritance method:

New Thread ()

{

public void Run ()

{

System.out.println (" inherited way of anonymous inner class!!! ");

}

}. Start ();

Anonymous inner class for interface mode:

Runnable r = new Runnable ()

{

public void Run ()

{

SYSTEM.OUT.PRINTLN (" Interface way of anonymous inner class!!! ");

}

} ;

New Thread (R). Start ();

Multi-Threaded---priority &yield method

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.