本帖最后由 艺多不压身丶 于 2015-2-16 23:05 编辑
- package pack;
- class ThreadTest3{
- public static void main(String[] args){
- new Thread(){
- public void run(){
- for(int x=0; x<50; x++)
- System.out.println(Thread.currentThread().getName()+"Thread :"+x);
- }
- }.start();
- new Object(){
- public void run(){
- for(int x=0; x<50; x++)
- System.out.println(Thread.currentThread().getName()+"Object :"+x);
- }
- }.run();
- Runnable r=new Runnable(){
- public void run(){
- for(int x=0; x<50; x++)
- System.out.println(Thread.currentThread().getName()+"Runnable :"+x);
- }
- };r.run();
- for(int x=0; x<50; x++)
- System.out.println(Thread.currentThread().getName()+x);
- }
- }
复制代码
以上代码体现,请问程序结果。变量X会出现重名错误吗? |
|