IllegalMonitorStateException...Help!
I am having an Illegal Monitor State Exception error. I have read the java API multiple times and I know why this exception is thrown, I just don't know how to fix it. Can someone please help? I have been working on this for a while and I have tried multiple ways to implement this. I am open to suggestions! The error occurs with the line mainThread.wait();
public class ThreadControl {
private Tier tierPanel;
private Thread mainThread, appThread;
private BallApp _ballApp;
public ThreadControl() {
tierPanel = new Tier(this);
mainThread = new Thread(tierPanel, "Tier");
}
synchronized void resumeTier() {
try{ appThread.wait(); }
catch(InterruptedException e) {}
mainThread.notify();
}
synchronized void startTier() {
mainThread.start();
}
synchronized void startBallApp(int FORstartValue1, int startValue2, int startValue3, int startValue4, int startValue5,
int startValueGC, int startValueIPA, int startValueNumAssim, int startValueNumActors) throws InterruptedException {
_ballApp = new BallApp("ID1_"+FORstartValue1+"finalData.txt", "ID1_"+FORstartValue1+"clusterData.txt", "ID1_"+FORstartValue1+"charData.txt",
FORstartValue1, startValue2, startValue3, startValue4, startValue5, startValueGC, startValueIPA, startValueNumAssim, startValueNumActors, this);
appThread = new Thread(_ballApp, "BallApp");
mainThread.wait();
appThread.start();
}
private static void createAndShowGUI() {
ThreadControl theThreadController = new ThreadControl();
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}

