This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Similar Threads
Java Threads 2nd edition: ATM locking example does not synchronize. WHY?
Regarding Syncronization
Synchronised Vs. Non synchronised Thread
synchronized - K&B sample
Thread question