和多线程无关。  直接setText就可以了。不按另一个不重设。按了后重设就可以了。

解决方案 »

  1.   

    抱歉,我说的不太明白,就是我想让一句话比如"how are you",重复显示一万遍,甚至更多,但是在我不中断它之前,就让"how are you"这句话永远重复显示下去。这样,应该怎样做?
      

  2.   

    在一个thread的run方法
    用一个boolean的flag为标记
    while(flag){...
    }
    在令一个thread里控制这个flag!
      

  3.   

    下面的程序稍做改动就是你想要的效果.
    在下面的例子中点击start按扭线程开始工作:每隔一秒钟显示一次当前时间;
    点击stop按扭后,线程就结束了生命,再点击start按扭,线程已经不能再开始工作了。import java.awt.event.*;import java.awt.*;import java.util.Date;class Example19_11 extends Frame implements Runnable, ActionListener{     Thread thread=null;     TextArea text=null;    Button b_start=new Button("Start"), b_stop=new Button("Stop");     Example19_11(){        thread = new Thread(this);        text=new TextArea();        add(text,"Center");        Panel p=new Panel();        p.add(b_start);         p.add(b_stop);         b_start.addActionListener(this);        b_stop.addActionListener(this) ;        add(p,"North");        setVisible(true);        setSize(500,300);        pack();        setResizable(false);                   //让窗口的大小不能被调整。        addWindowListener(new WindowAdapter(){           public void windowClosing(WindowEvent e){             System.exit(0);           }        });  }  public void actionPerformed(ActionEvent e){      if(e.getSource()==b_start){           try {                  thread.start();           } catch(Exception e1){                  text.setText("在线程没有结束run方法之前,不赞成让线程再调用start方法");           }       } else if(e.getSource()==b_stop){            thread.interrupt();                   //会抛出InterruptedException     } } public void run() {       while(true){           text.append("\n"+new Date());            try{                  thread.sleep(1000);            }catch(InterruptedException ee){                   text.setText("我被消灭");                   return;      //结束run语句,消灭该线程。            }       }   }  public static void main(String args[]){        Example19_11 tt=new Example19_11();  }} 
      

  4.   

    何苦呢?
    setText("How are you")
    按下另一个按钮后
    setText("")
    不就ok了?