• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What Diff. Between MyClassName.this and this? When use each?

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually I see:
synchronized ( this ) {
...blah, blah...
}
But recently I saw:
synchronized ( AdminLeaseService.this )
{
...blah, bleh.....
}
Is there a difference? Is one safer than the other? Is there a point where one will work and the other won't? For example, in RMI?
[ August 23, 2002: Message edited by: Robert Paris ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're inside an inner class, "this" refers to the current instance of the inner class. You also may need to refer to the current instance of the outer class - that's where notation like OuterClassName.this is necessary. I don't think there's any other use for it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic