Java Method suspend\resume\yield\setpriority

Source: Internet
Author: User

Suspend and Resuem are also not recommended, and are likely to throw some exceptions when used. For example, suspend a synchronization object, which prevents the lock from being interpreted, and other threads will not be able to continue execution while accessing the object. The simplest example could be System.out.println, which is a synchronous method that, if executed in a thread and suspend, cannot continue to use the SYSTEM.OUT.PRINTLN output in the main method because it has been paused and the exclusive resource cannot be interpreted.

Yield method to transfer the current CPU resources to other tasks to perform the use.

setpriority (int) To set the priority level. The priority range is

Min_priority=1,

MAX_PRIORITY=10,

Norm_priority=5

The priority of a thread is inherited, such as a boy thread, and the child thread is the same priority as the boy thread.



This article is from the "Happy Cup of Tea" blog, please be sure to keep this source http://gugw9handsome.blog.51cto.com/1187812/1784204

Java Method suspend\resume\yield\setpriority

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.