日期:2014-05-20 浏览次数:20765 次
public class TestMain {
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) {
System.out.println("主线程开始执行");
try {
ThreadTest1 test1 = new ThreadTest1();
Thread t1 = new Thread(test1);
t1.start();
for(int i=0;i<1000;i++){
System.out.println("我是主线程");
}
t1.join();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("主线程执行完毕");
}
}
public class ThreadTest1 implements Runnable {
@Override
public void run() {
for(int i=0; i<1000; i++){
System.out.println("我是线程1--" + i);
}
}
}