wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 180
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:

I agree. Here's the link: http://aspose.com/file-tools
subject: Threads Synchronization
Similar Threads
Devaks's PracticeExam1 Q:44 and Q72
Thread outuput predictable or not
question about thread output from examlab practice test 1
Basics of Thread and Synchronization