public class MyThread implements Runnable{
@Override
public void run() {
for(int i=0; i<20; i++){
System.out.println(Thread.currentThread().getName()+"-"+i);
}
}
public static void main(String[] args) {
Thread t1 = new Thread(new MyThread());
Thread t2 = new Thread(new MyThread());
t1.start();
t2.start();
}
}
public class MyThread extends Thread{
@Override
public void run() {
for(int i=0; i<20; i++){
System.out.println(Thread.currentThread().getName()+"-"+i);
}
}
public static void main(String[] args) {
new MyThread().start();
new MyThread().start();
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |