//线程的创建方法1 class Xc extends Thread { public void run (){ for ( int i = 0 ; i 20 ; i ++ ){ System . out . println ( "我是歌谣" ); } } } public class test27 { public static void main ( String [] args ){ Xc xc = new Xc (); xc
class Xc extends Thread {
public void run(){
for (int i=0;i<20;i++){
System.out.println("我是歌谣");
}
}
}
public class test27{
public static void main(String[] args){
Xc xc=new Xc();
xc.start();//程序会自动调用run方法
for (int i=0;i<20;i++){
System.out.println("我是逍遥");
}
}
}
理论上会出现歌谣和逍遥交替出现,由于太少循环,效果不明显