线程
public class TestThread1{ public static void main(String args[]){ Runner1 r=new Runner1(); r.run(); //Thread t=new Thread(r);//方法1 //t.start();//方法1 for (int i =0;i<100;i++){ System.out.println("Main Thread:---------" + i); } } } class Runner1 implements Runnable{ public void run(){ for (int i =0;i<100;i++){ System.out.println("Runner1:" + i ); } } }
Start:Runner1和Main Thread交替运行。
run:Runner1先运行,Main Thread后运行
时间: 2024-10-14 02:08:26