File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Understanding contention examples in developerWorks article Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Understanding contention examples in developerWorks article" Watch "Understanding contention examples in developerWorks article" New topic
Author

Understanding contention examples in developerWorks article

HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
Hi,
I'd appreciate if anyone can help to explain to me why if a thread is executing setUserInfo in the following code will locked out thread of getServiceInfo and setServiceInfo as well.

As explained in an article in
http://www-106.ibm.com/developerworks/java/library/j-threads2.html
Technique 2 : Reducing lock granularity
I appreciate any advice.
Cheers.

Han Ming
Thomas Thomas
Greenhorn

Joined: Jun 17, 2003
Posts: 28
Hi
u cannot run two synchronized methods of the same object at a time bcz the lock is given by the object and it has only one lock.
if u r using a complex method in which a small part is to be synchronized .u can synchronized blocks
synchronized(this/object){
}
I hope i didn't misunderstand u r question.
thomas
HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
Hi,
Thanks for the reply.
That answers my question.

Cheers.

Han Ming
 
 
subject: Understanding contention examples in developerWorks article
 
Threads others viewed
Singleton Design Pattern
How to use Concurrency Utilities ??
Excellent JSTL article from ibm developerworks
lifecycle of session and request
What is ThreadLocal
developer file tools