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