In this example the wait and notify should be avoided. Because once executing the syncronized method the book is already in use,yes , but by the thread itself executing the method. Thus if the thread ever waits, it is for lending the book that alredy had. I guess that is not the goal. In fact it is enough to mark the method as synchronized and forget about the available flag, wait and notify.
There are two ways of synchronizing threads:
1) For sharing a common resource.
The intention is to avoid the access to a commom resource simultaneously by several threads. The program is an example of that.
2) For cooperating in a commom task.
A thread process until it reaches a point in which it can not go on. It must wait for another thread to process. This second thread runs untill it reaches a point in which it can not go on. It has already done the work that will allow the first thread to continue. Thus the second thread will notify the first one. An the process will repeat itself.
An example of such scenario can be found in the
Java Tutorial at java.sun.com
It is called the producer-consumer scenario. One thread consumes what the other produces.