although I've slightly modified lines 9 & 11 to include the thread name in the output.
According to K&B's answer:
With either fragment, the first output must be yo.
I don't see why this must be so. I think that if the unsynchronized chat() is used, as above, then thread t1 could get to line 6 first & set the flag to its own id. Then, thread t2 could get some processor time and start executing chat(). The flag != 0 by now, so t2 leaves the flag unchanged and since the flag doesn't equal its own id, [dude] gets printed first.
In fact, running the program, occasionally [dude] does get printed first.
Maybe I should post to the 'Compiling errata for K&B, SCJP 6' thread, it's not currently mentioned there.