ggbond1988
级别: 新手上路
只看楼主 | | | 0 发表于:2010-05-27 10:04

0 java中thread与main()方法??

class MyThread implements Runnable{ // 实现Runnable接口 +^tw@b  
public void run(){ // 覆写run()方法 $9In\ x  
  for(int i=0;i<5;i++){ Qf<@ :T*  
   try{ /GDGE }  
     Thread.sleep(500) ; // 线程休眠 yw{;Qm2\7  
   }catch(InterruptedException e){ 1~_&XNb;&  
    } qL1 d-nH  
   System.out.println(Thread.currentThread().getName() * U#@M3g.  
     + "运行,i = " + i) ; // 取得当前线程的名字 r@9 qjva  
  } N-9qNL SP  
} V {H/>>k7  
}; jh3X G  
public class ThreadSleepDemo{ ~3F\7%Iqc  
public static void main(String args[]){ LsGu-Y 5^  
  MyThread mt1= new MyThread() ; // 实例化Runnable子类对象 +CF"Bm8@  
  Thread t1 = new Thread(mt1,"线程");  // 实例化Thread对象 ?5yj</W  
  t1.start() ; // 启动线程 =O?#>3A}  
  System.out.println("hi,dandan"); vxrRkOU1  
   *[MK {m  
} 1FO T  
}; ED kxRfY2/  
D#?jddr-  
我在主方法中写了一个System的方法在启动线程之后,但是运行结果是: M zbs #v0  
先运行System而后运行start方法。 k5=VH5{S  
这是怎么回事呢? xn)eb#r  
是System的优先级高?还是? =b* Is,R/