File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes Synchronized block Vs Concurrent Lock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Synchronized block Vs Concurrent Lock" Watch "Synchronized block Vs Concurrent Lock" New topic
Author

Synchronized block Vs Concurrent Lock

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1367
Which gives best performance Synchronized block / Concurrent Lock ?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7032
    
  16

kri shan wrote:Which gives best performance Synchronized block / Concurrent Lock ?

In theory, the latter is supposed to be more scalable, and does allow a bit more flexibility; but it comes at the expense of more code and thus more chances for "getting it wrong" and/or making things less readable.

Unless you're actually writing a critical multi-tasking system, I'd suggest you only use the latter if you can prove that it makes sense. And that means LOTS of testing of both forms.

Winston
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronized block Vs Concurrent Lock
 
Similar Threads
exception in sync block
synchronized and ReentrantReadWriteLock
synchronized
Synchronizing Code
Synchronized method and Sychronized block