public class MainGuiTest extends javax.swing.JFrame {
private Thread t = new Thread(new TarefaContinua());
public MainGuiTest() {
initComponents();
}
public static void main(String args[]) {
new MainGuiTest().setVisible(true);
}
ActionListener ActionStart = new ActionListener() {
public void actionPerformed(ActionEvent e) {
t.start();
}
};
ActionListener ActionPause = new ActionListener() {
public void actionPerformed(ActionEvent e) {
jTextArea1.append("\nProcesso em espera...");
try{
t.wait();
}catch(InterruptedException ie){
jTextArea1.append("\nErro: "+ie.getMessage());
}
}
};
ActionListener ActionResume = new ActionListener() {
public void actionPerformed(ActionEvent e) {
jTextArea1.append("\nProcesso retomado...");
t.notify();
}
};
public class TarefaContinua implements Runnable {
public void run() {
for(int w=1; w<=5000; w++){
MainGuiTest.jTextArea1.append("\nec.VerificaIndividuos();"+w);
}
}
}
Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException: current thread not owner...Entendo, mas porque não? Ele está dando preferência para a Thread do Swing, é isso? Porque eu já criei uma Thread separada apenas para a tarefa, para não misturar com a Thread do Swing... Alguém sabe porque a Thread t não está conseguindo ser pausada? []´s!