Why isn't Object.notify() a synchronized method?

Vitaly Davidovich vitalyd at gmail.com
Thu May 28 16:13:51 UTC 2015


What would synchronized on that method help with? Typically you do
something while holding the lock and then notify while still holding the
lock.

sent from my phone
On May 28, 2015 12:09 PM, "Ulf Zibis" <Ulf.Zibis at cosoco.de> wrote:

> Hi all,
>
> in the Javadoc of notify(), notifyAll() and wait(...) I read, that this
> methods should only be used with synchronisation on it's instance.
> So I'm wondering, why they don't have the synchronized modifier out of the
> box in Object class.
>
> Also I think, the following note should be moved from wait(long,int) to
> wait(long):
> /The current thread must own this object's monitor. The thread releases
> ownership of this monitor and waits until either of the following two
> conditions has occurred://
> /
>
>  * /Another thread notifies threads waiting on this object's monitor to
> wake up either through a
>    call to the notify method or the notifyAll method./
>  * /The timeout period, specified by timeout milliseconds plus nanos
> nanoseconds arguments, has
>    elapsed. /
>
>
>
> Cheers,
>
> Ulf
>
>



More information about the core-libs-dev mailing list