SCJP 5 (100%)
------------------------
Bob
SCJP - 86% - June 11, 2009
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
It does. Line 34.Ankit Garg wrote:...Notify cannot do anything as Main thread never waits on t object..
Ankit Garg wrote:... But the notify call will do nothing as no other thread is 'waiting' on t object...
? It lets Main thread to wake up and get the data. Doesn't it?Ankit Garg wrote:... notify call will do nothing ..
Ankit Garg wrote: Its true after each iteration, main method will get a chance to grab a lock on t, but even if that happens, then also this code will run only once and not after each iteration
it seems, that following changes do the work:
...
Do I missing safety this way?
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:IHow could I not notice the while loop and the wait call
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:Well your program still doesn't gives the guaranteed behavior of the result you want. Actually you won't get the correct result most of the times. You need to do something more complicated to get reliable output
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|