package test;import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;public class Test1 extends Applet implements ActionListener, MouseListener {
Thread thread; String command; Object result; boolean isEnd = false; Button dLine; int count = 0; public void init() {
dLine = new Button("畫線");
this.add(dLine);
this.addMouseListener(this);
dLine.addActionListener(this);
} public void mouseClicked(MouseEvent e) {
this.call();
}
public void start() {
thread = new Thread(new Runnable() {
public void run() {
System.err.println("isEnd========" + isEnd);
while (!isEnd) {
try {
synchronized (thread) {
thread.wait();
}
} catch (Exception e) {
e.printStackTrace();
}
if (isEnd)
return;
try {
System.err.println("count======" + count);
count++;
if ("CallExe".equals(command))
result = callExe();
} catch (Exception e) {
e.printStackTrace();
}
synchronized (Test1.this) {
Test1.this.notify();
}
}
}
});
thread.start();
} public void stop() {
System.err.println("stop!!!!");
isEnd = true;
synchronized (thread) {
thread.notify();
} } String call() {
this.command = "CallExe";
try {
synchronized (thread) {
thread.notify();
}
synchronized (this) {
wait();
}
} catch (Exception e) {
e.printStackTrace();
}
return (String) result;
} String callExe() {
System.err.println("isfdsf");
// todo add logic here
return null;
} public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub } public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub } public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub } public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub } public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub }}
--------------------------------------------------------------------------
以上代码为什么在点击100次以上的时候会死掉?