"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
Siva Masilamani wrote:Try getting lock on "r" instead of t.
quote]
Siva,
Just saw the second message you posted. If I get a lock on "r" instead of "t" (which was the first thing I tried), it doesn't work. "t.wait()" gives the IllegalMonitorStateException. It seems that to execute wait() on t, the lock has to be on t![]()
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Nidhi Sar wrote:
Siva Masilamani wrote:Try getting lock on "r" instead of t.
quote]
Siva,
Just saw the second message you posted. If I get a lock on "r" instead of "t" (which was the first thing I tried), it doesn't work. "t.wait()" gives the IllegalMonitorStateException. It seems that to execute wait() on t, the lock has to be on t![]()
You have to use "r" on both wait and synchronized block.then it should be OK.
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
Siva Masilamani wrote:
You have to use "r" on both wait and synchronized block.then it should be OK.
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
Siva Masilamani wrote:i am wondering how the main thread gets its turn eventhough you did not notify via Thread Object in your previous case?
did you get that point?
i am talking about previous case.
I though the main thread would not stop as no thread notifies it but the output shows main thread got lock back........
Steve
SCJP 6,SCWCD 5,SCBCD 5
Failure is not an option.
Consider Paul's rocket mass heater. |