The performance issue here is mostly a red herring.
The reason notify() is not synchronized has much more to do with
correctness; when you "forget" to wrap your notify call with lock
acquisition, it is almost always a bug. (The rest of this explanation
is probably clearer if you've read JCiP
On Sun, May 31, 2015 at 02:31:25PM +1000, David Holmes wrote:
> >As I recently fell into the trap of forgetting the synchronized block
> >around a single notifyAll(), I believe, the current situation is just
> >errorprone.
>
> How is it errorprone? You forgot to acquire the lock and you got an
> I
On 30/05/2015 2:48 AM, Ulf Zibis wrote:
Thanks for your hint David. That's the only reason I could imagine too.
Can somebody tell something about the cost for recursive lock
acquisition in comparison to the whole call, couldn't it be eliminated
by Hotspot?
There are a number of fast paths relat
Thanks for your hint David. That's the only reason I could imagine too.
Can somebody tell something about the cost for recursive lock acquisition in comparison to the whole
call, couldn't it be eliminated by Hotspot?
As I recently fell into the trap of forgetting the synchronized block around a
On 29/05/2015 2:08 AM, Ulf Zibis 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.
Because, as
Since most of the time you have to hold the lock anyway for other
reasons, I think this would generally be an unwelcome change since I
expect the cost of recursive lock acquisition is nonzero.
On 05/28/2015 11:08 AM, Ulf Zibis wrote:
Hi all,
in the Javadoc of notify(), notifyAll() and wait(..
On 05/28/2015 07:08 PM, Ulf Zibis 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.
W
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" wrote:
> Hi all,
>
> in the Javadoc of notify(), notifyAll() and wait(...) I read, that this
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 f