This is what i was talking about. (It is for jdk 5 and above but you can use the same idea in lower jdk versions also)
The benefit of using different conditions for odd and even printing is that you exactly know which thread you will be signalling.
If you use the instance lock (synchronized keyword) then it may be a possibility that someone extends the class and adds one more synchronized method and starts waiting on the instance monitor. That will introduce subtle bugs in your code.
The only idea of doing the above is to have a better control.
There is an alternative way of doing this by using
Exchanger I am sure you will get an idea on how to use that by seeing its javadoc.
Happy learning.
[ June 18, 2008: Message edited by: Nitesh Kant ]