• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads

 
mamidi venkat
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

What is the difference between Synchronized Block and Synchronized method with an example .confused with this.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following two are the same:

Do you now understand what it means if you make a method synchronized?
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a synchronized block you can choose to only synchronize part of the code in the method. With a synchronized method, all the code in the method is synchronized.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And with a synchronized block you can choose what to synchronize on. With a synchronized method, an instance method always synchronizes on the instance, a static method always synchronizes on the class.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic