您的位置:首页 > 编程语言 > Java开发

Java线程常用操作方法(线程优先级)

2018-02-12 16:29 197 查看
class Mythread implements Runnable {
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(Thread.currentThread().getName()+",x="+i);
}

}

}

public class MythreadDemo03 {
public static void main(String[] args) throws Exception {
Mythread mt01 = new Mythread();
Thread t1=new Thread(mt01, "自己的线程对象A");
Thread t2=new Thread(mt01, "自己的线程对象B");
Thread t3=new Thread(mt01, "自己的线程对象C");
t1.setPriority(Thread.MAX_PRIORITY);
t1.start();
t2.start();
t3.start();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息