Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Threads
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Threads and Synchronization
Difference between synchronized method and synchrnoized block of code
subramanian annamalai
Greenhorn
Posts: 22
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 24207
46
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
There's essentially no difference between
public synchronized int foo() { // ... }
and
public int foo() { synchronized(this) { // ... } }
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.
[Jess in Action]
[AskingGoodQuestions]
bart zagers
Ranch Hand
Posts: 234
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I can not better explain it then described
here
.
Gregg Smith
Greenhorn
Posts: 2
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks!! This helped me!!
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
synchronized methods are a temporary hack which should never be used.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Difference between synchronized method and synchrozed block
Synchronized Block and Synchronized method
Differrence Between Synchronized Method and Synchronized Block
differences between synchronized blocks and synchronized() method
what is synchronization
More...