public class ButtonPressed implements ActionListener SortThread thread

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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());
}
}
}
}