Luan Cestari wrote:I don't know if it is clear for you, but you just need to put "synchronized" into the method (or code blocks) to be the ownership of the monitor (by default it uses the "this" as the monitor object ).
Although you are right in that is how you get ownership of the lock, just putting synchronized does not really let wait() work, it just prevents the exception. That is why Tim and I pointed the OP to documentation on how to use the method, rather than just telling him how to avoid an exception.