java线程的循环跳出问题

做了一个线程的试验,结果不能跳出for循环,怎么回事?望解答

 public class Mythread {

    public static void main(String[] args) {

        new Extendsthread("wo");
        new Extendsthread("my");
        Thread m=Thread.currentThread();

        System.out.println("this is main thread...." 
        + "     " + m.getName());
        System.out.println("the next express:   " + m);
    }

}

class Extendsthread extends Thread{

    Thread t;
    Extendsthread(String name){
        t=new Thread(this,name);
        t.start();
    }

    public void run(){
        for(int i=0;i<5;i++){
            System.out.println(t.getName()+i);

            if(t.getName()=="wo")
                break;

            System.out.println("skip break!!!!");
            System.out.println("this is child thread: " 
            + i + t +"   \n" + t.getName());

        }
    }
}
查看全部
wang2046783134
wang2046783134
2015/08/07 07:20
  • java
  • 线程
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

6个回复