运行一下这个程序:(感觉是对的,怎么IE闪一下就没了啊?)
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class number extends Applet implements Runnable,ActionListener
{
Button button;
Thread thread1,thread2;
TextField text1,text2;
public void init()
{
text1=new TextField(20);
text2=new TextField(20);
add(text1);
add(text2);
button=new Button("starts thread");
add(button);
button.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==button)
{
thread1=new Thread(this,"threadname1");
thread1.start();
thread2=new Thread(this,"threadname2");
thread2.start();
}
}
public void run()
{
String s=new String();
int i;
for(i=0;i<1000;i++)
{
if(((Thread.currentThread()).getName()).equals("threadname1"))
text1.setText(s.valueOf(i));
else 
if(((Thread.currentThread()).getName()).equals("threadname1"))
  text2.setText(s.valueOf(i));
}
}
}