David,

Thanks for taking a closer look.  Really appreciate your detailed review.

On 6/23/11 1:33 PM, David Holmes wrote:
Sorry for the delay on this ...

I concur with Mandy that using arrive() the thread must always be
RUNNABLE or the expected next state. Hence the new check is ok.

With the new synchronization (and perhaps even the old) it seems to me
that here:

private void setState(int newState) {
switch (state) {
case BLOCKED:
while (state == BLOCKED) {
goSleep(20);
}
state = newState;
break;

the sleep loop is unnecessary as after setting the new state the main
thread will call arriveAndAwaitAdvance.
>
Also here:

try {
Thread.sleep(1000000);
} catch (InterruptedException e) {
// finish sleeping
interrupted();
}

the interrupted() call is redundant as the interrupt state is already
cleared when the IE is thrown.

Good catch. The sleep loop and the interrupted() call are indeed not needed.

Mandy

Reply via email to