This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Getting MEAN with Mongo, Express, Angular, and Node and have Simon Holmes on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes synchronized - K&B sample Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "synchronized - K&B sample" Watch "synchronized - K&B sample" New topic

synchronized - K&B sample

Anthony Karta
Ranch Hand

Joined: Aug 09, 2004
Posts: 342
I modified money withDrawal illustration in K&B book by putting makeWithDrawal() method in another class called AccountTrans.

But I got different behaviour/output, until I put that line which called makeWithDrawal() in synchronized(this) block.

anyone can explain why I need to synchronized on "this" object and
synchronized on "public void makeWithDrawal" doesn't work anymore?

hope make sense

I agree. Here's the link:
subject: synchronized - K&B sample