File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads Synchronization" Watch "Threads Synchronization" New topic

Threads Synchronization

Balaji Bang
Ranch Hand

Joined: Apr 23, 2007
Posts: 182

I am talking about Devaka's Practice Exam-1 Q:72.

I made simple change in this..

In main method if the synchronized block has lock on object SynchEx that is 'ss' then synchronization works. if it is td then it will go and run method before it completes main. So in run() 'this' is the ss not 'td' ..

I understood like this. Am I Right???
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Yes, you are correct.

All code in my posts, unless a source is explicitly mentioned, is my own.
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
Yes, it is due to method in thread class.

It means for you:

I agree. Here's the link:
subject: Threads Synchronization
It's not a secret anymore!