package ThreadDemo;
public class ThreadTest {
public static void main(String [] args){
new Thread(new Runnable() {
int y=0;
@Override
public void run() {//匿名内部类的run方法。
System.out.println("runnable"+Thread.currentThread().getName()+"..."+y++);
}
}){
int x=0;
@Override
public void run(){//匿名对象Thread的run方法
while(true){
System.out.println("thread"+Thread.currentThread().getName()+"..."+x++);
}
}
}.start();
}
}
|
|