Java----线程的基本信息和优先级

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Miracle_Gaaral/article/details/89071371

一.基本信息

    

二.优先级

package com.kennosaur.thread;
/**
 * 优先级: 代表的是概率,不是绝对的先后顺序	
 * MAX_PRIORITY  10
 * NORM_PRIORITY  5  默认
 * MIN_PRIORITY  1
 * 
 * setPriority()   设置优先级
 * getPriority()   获取优先级
 * @author Administrator
 *
 */

public class Info02 {
	public static void main(String[] args) throws InterruptedException {
		InfoThread t1 = new InfoThread();
		Thread p1 = new Thread(t1,"IT1");
		InfoThread t2 = new InfoThread();
		Thread p2 = new Thread(t2,"IT2");
		
		p1.setPriority(Thread.MIN_PRIORITY);  //设置优先级
		p2.setPriority(Thread.MAX_PRIORITY);  //设置优先级
		p1.start();
		p2.start();
		
		Thread.sleep(10);
		t1.stop();
		t2.stop();
	}
}

猜你喜欢

转载自blog.csdn.net/Miracle_Gaaral/article/details/89071371