黑马程序员技术交流社区

标题: 线程的优先级问题 [打印本页]

作者: 357016138    时间: 2014-7-28 18:02
标题: 线程的优先级问题
  1. 是不是主线程的优先级比下面的t线程优先级高?
复制代码


作者: 357016138    时间: 2014-7-28 18:04

  1.     public class ThreadTest {
  2.         public static void main(String args[]) {
  3.         MyThread t = new MyThread();
  4.         t.run();
  5.         t.start();
  6.         System.out.println("A");
  7.         }
  8.     }

  9.     class MyThread extends Thread {
  10.         public void run() {
  11.             try {
  12.                 Thread.sleep(3000);
  13.                 } catch (InterruptedException e) {
  14.              }
  15.             System.out.println("B");
  16.             }
  17.     }
复制代码

作者: masai158    时间: 2014-7-28 18:07
run 是调用方法吧。。。start 才是开启线程
作者: 乐此不疲    时间: 2014-7-28 19:44
不刻意设定的话都是默认的NORM_PRIORITY   




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2