• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

synchronized - K&B sample

 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic