• Post Reply Bookmark Topic Watch Topic
  • New Topic

run() method  RSS feed

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hvae one confusion ,
here is the code :



In the above class there I can write two different kind of run method :
1)1st form


2)2nd form



What is the difference between these two run methods ? which one is better to use ?


regards,
S
 
Vijitha Kumara
Bartender
Posts: 3972
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s begri wrote:What is the difference between these two run methods ? which one is better to use ?

It may depends on the requirement. Using "this" synchronizes on the current instance, and with "Letter.class" synchronizes on the Class object represents the "Letter" class in the JVM.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!