Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads Synchronization

 
Balaji Bang
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1032
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are correct.
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is due to Thread.run() method in thread class.



It means for you:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic