Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between synchronized method and synchrnoized block of code  RSS feed

 
subramanian annamalai
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can somebody explain the basic difference of defining a method with Synchronized modifer with Synchronized block of code. i am bit confused.

Thanks
Subu
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's essentially no difference between



and



Synchonized blocks give you more flexibility, though, because you can synchronize on another object besides "this", or you can synchronize only part of a method rather than the whole thing.
 
bart zagers
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can not better explain it then described here.
 
Gregg Smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!! This helped me!!
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
synchronized methods are a temporary hack which should never be used.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!