Java??3ì£o??3ìμ?μ÷?è-ó??è??
ê±??:2011-02-20 51cto2??í leizhimin
??3ìμ?ó??è??ó?1-10????μ???êy±íê?£?êy?μ??′óó??è??????£???è?μ?ó??è???a5?£
?úò?????3ì?D?a??áííaò???D???3ì£??òD??a??3ì3??a????3ìμ?×ó??3ì£?×ó??3ì3?ê?ó??è??ó?????3ì?àí??£
/**
*??Java??3ì£o??3ìμ?μ÷?è-ó??è??
*
*??@author??leizhimin
*/
public??class??Test??{
???????????????? public??static??void??main(String[]??args)??{
???????????????????????????????? Thread??t1??=??new??MyThread1();
???????????????????????????????? Thread??t2??=??new??Thread(new??MyRunnable());
???????????????????????????????? t1.setPriority(10);
???????????????????????????????? t2.setPriority(1);
???????????????????????????????? t2.start();
???????????????????????????????? t1.start();
???????????????? }
}
class??MyThread1??extends??Thread??{
???????????????? public??void??run()??{
???????????????????????????????? for??(int??i??=??0;??i??<??10;??i++)??{
???????????????????????????????????????????????? System.out.println("??3ì1μú"??+??i??+??"′??′DD£?");
???????????????????????????????????????????????? try??{
???????????????????????????????????????????????????????????????? Thread.sleep(100);
???????????????????????????????????????????????? }??catch??(InterruptedException??e)??{
???????????????????????????????????????????????????????????????? e.printStackTrace();
???????????????????????????????????????????????? }
???????????????????????????????? }
???????????????? }
}
class??MyRunnable??implements??Runnable??{
???????????????? public??void??run()??{
???????????????????????????????? for??(int??i??=??0;??i??<??10;??i++)??{
???????????????????????????????????????????????? System.out.println("??3ì2μú"??+??i??+??"′??′DD£?");
???????????????????????????????????????????????? try??{
???????????????????????????????????????????????????????????????? Thread.sleep(100);
???????????????????????????????????????????????? }??catch??(InterruptedException??e)??{
???????????????????????????????????????????????????????????????? e.printStackTrace();
???????????????????????????????????????????????? }
???????????????????????????????? }
???????????????? }
}
??3ì1μú0′??′DD£?
??3ì2μú0′??′DD£?
??3ì2μú1′??′DD£?
??3ì1μú1′??′DD£?
??3ì2μú2′??′DD£?
??3ì1μú2′??′DD£?
??3ì1μú3′??′DD£?
??3ì2μú3′??′DD£?
??3ì2μú4′??′DD£?
??3ì1μú4′??′DD£?
??3ì1μú5′??′DD£?
??3ì2μú5′??′DD£?
??3ì1μú6′??′DD£?
??3ì2μú6′??′DD£?
??3ì1μú7′??′DD£?
??3ì2μú7′??′DD£?
??3ì1μú8′??′DD£?
??3ì2μú8′??′DD£?
??3ì1μú9′??′DD£?
??3ì2μú9′??′DD£?
Process??finished??with??exit??code??0
3?′|£ohttp://lavasoft.blog.51cto.com/62575/221801 |