public class ButtonPressed implements ActionListener {
SortThread thread;
public ButtonPressed(SortThread thread) {
this.thread = thread;
}
public void actionPerformed(ActionEvent e) {
synchronized (thread) {
if (e.getActionCommand() == "Start")
thread.run();
else
try {
thread.wait(1000);
} catch (InterruptedException ex) {
System.out.println(ex.getMessage());
}
}
}
}