This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The question says: Which of the following statements about threading are true 1) You can only obtain a mutually exclusive lock on methods in a class that extends Thread or implements runnable 2) You can obtain a mutually exclusive lock on any object 3) A thread can obtain a mutually exclusive lock on a method declared with the keyword synchronized 4) Thread scheduling algorithms are platform dependent I knew that 2 & 4 are correct but it also says 3 is true. I thought locks are obtained for objects. If you put the synchronized modifier in front of a method doesn't it mean to synchronize on the class (object)?? thanks!
I'm not sure but this concept of thinking thread kinda helps me. When u declare synchronized method, the method is like a door that allows only a single thread that has the lock for an object associated with the method. When they say "thread can obtain a lock from synch. method", i think it might be refering to how the synchronized method works. Once a thread leaves the sync. method, the leaving thread gives up the lock that any thread can pick up and use to enter the same method. That way sync method effectively prevents multiple threads from entering the method. Reading Synchronized methods section in RHE might help. please, anyone correct me if i said something wrong regards
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com