Condition vs wait notify mechanism

The biggest problem is that wait/notify is error prone for new developers. The main problem is not knowing how to handle them correctly can result is obscure bug.

  • if you call notify() before wait() it is lost.
  • it can be sometimes unclear if notify() and wait() are called on the same object.
  • There is nothing in wait/notify which requires a state change, yet this is required in most cases.
  • wait() can return spuriously

Condition wraps up this functionality into a dedicated component, however it behaves much the same.

There is a question regarding wait/nofity posted minutes before this one and many, many more Search [java]+wait+notify

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)