003 Thread Properties

Source: Internet
Author: User

I. Overview

Thread properties: Several properties are described in a thread, and here we mainly talk about common thread properties.

Two. Thread Properties

[1] ID: The ID of the thread, a thread will have a unique ID, we do not need to manage it.

[2]name: The name of the thread, in the creation of the thread, we can specify the name of the thread, by default it will have its own name, which is provided by the thread by default.

[3] Priority: The priority describes the proportion of the thread being prioritized during execution, which cannot be used as a basis for our thread order execution, and each operating system has a different mapping for this.

That is, high-priority threads are not necessarily more likely to execute than low-priority threads, but in large probabilities, high-priority is more than the number of low-priority runs.

[4]status: The state of the thread, which is the previously mentioned thread state, which describes the current running condition of the thread.

Three. Setting properties for a thread

An example is given below:

@Test      Public void Property () {        new  Thread ();        Thread.setname (" thread one ");        Thread.setpriority (thread.max_priority);    }

The code above gives you a way to set a thread's properties, and note that you need to set it before you start it.

Note: the definition of thread precedence is given in the thread class, which is different from the level of mapping in different grass group systems.

003 Thread Properties

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.