When you invoke java.lang.Object.wait() in a synchronized context (which is a pre-condition) the invoking
Thread effectively relinquishes the object's intrinsic lock, which is why in this case the ouput for the two threads
can be intermingled. Have a look at API documentation of java.lang.Object for more information.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.