aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads Synchronization" Watch "Threads Synchronization" New topic
Author

Threads Synchronization

Balaji Bang
Ranch Hand

Joined: Apr 23, 2007
Posts: 180
Hi
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 Thread.run() method in thread class.



It means for you:



SCJP 6
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Threads Synchronization