wood burning stoves 2.0
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads: Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads: Doubt" Watch "Threads: Doubt" New topic

Threads: Doubt

dedcat achi

Joined: Jun 22, 2008
Posts: 11
Can someone please explain this:

"A thread can acquire more than one lock. For example, a thread can enter a synchronized method, thus acquiring a lock, and then immediately invoke a synchronized method on a different object, thus acquiring that lock as well. Also, if a thread acquires a lock and then attempts to call a synchronized method on the same object, no problem."

Can you please give an example this to explain the above statements.

Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

Here is an example

The lock of this object, System.out is obtained. Another synchronized method is called from the body of the synchronized block

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
dedcat achi

Joined: Jun 22, 2008
Posts: 11
I agree. Here's the link: http://aspose.com/file-tools
subject: Threads: Doubt
jQuery in Action, 3rd edition