I having some trouble with the IllegalMonitorStateException being thrown because I'm not calling notify from the correct place that is the monitor of the object I'm suspending. Unfortunatly I can't work out there the correct place is.
My setup is as follows:
main - creates a new object X
Action Event Thread - X uses a listener on an event which executes in Action Event Thread
Swing worker Thread - the action event thread creates a worker thread which runs a syncronised method in X
The method in X launches a dialog box then uses Thread.currentThread().wait(); to hold the worker thread.
Once the dialog box recieves another user action I want to resume the worker thread but can't seem to find the right place to do so sucessfully.
Do I need to notify the suspended thread from the thread that started the swing worker and if so, in this case, which thread is that? main, the action despatch thread or something else?
I have tried simply passing on the paused thread as a variable before hand so I can call thread.notify() from another synchronised method in X, but to no avail.
Question
Minchino
I having some trouble with the IllegalMonitorStateException being thrown because I'm not calling notify from the correct place that is the monitor of the object I'm suspending. Unfortunatly I can't work out there the correct place is.
My setup is as follows:
main - creates a new object X Action Event Thread - X uses a listener on an event which executes in Action Event Thread Swing worker Thread - the action event thread creates a worker thread which runs a syncronised method in XThe method in X launches a dialog box then uses Thread.currentThread().wait(); to hold the worker thread.
Once the dialog box recieves another user action I want to resume the worker thread but can't seem to find the right place to do so sucessfully.
Do I need to notify the suspended thread from the thread that started the swing worker and if so, in this case, which thread is that? main, the action despatch thread or something else?
I have tried simply passing on the paused thread as a variable before hand so I can call thread.notify() from another synchronised method in X, but to no avail.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts