whilst making a simple(ish) corba app using java I've been hitting my head
against a threading problem and as I don't often use them can't think of the
right design pattern to save me.
basically I have the constructore pausing with a wait() at a point and it
should resume when one of the other methods in the object is called. I have
tried putting notify() or notifyAll() witrhin that called method to awake
the main thread but I can't as I am constantly getting
illegalMonitorStateExceptions as the method can't mess with the lock on the
main thread.
anyone know a way around this? possibly a different design style?
My thanks -
Lloyd
p.s. below is part of the runtime error
java.lang.IllegalMonitorStateException
at java.lang.Object.notifyAll(Native Method)
at MatchMakerClient.swap(MatchMakerClient.java:87)
at Matching.AveragerPOA._invoke(AveragerPOA.java:41)
at
org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java
:207)
just attempted the solution described below in this newsgroup.
I now have an object I creat a lock on in the main thread, then when the
method is called by an external party I run a synchronized notifyall on that
object.
still a runtime error but now
ERROR : java.lang.IllegalMonitorStateException
java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:420)
at MatchMakerClient.<init>(MatchMakerClient.java:36)
at MatchMakerClient.main(MatchMakerClient.java:65)
joy
This means you are trying to call an object's wait method without being
synchronized on that particular object.
Patricia