I came across the code:

synchronized(Account.this)   
{}   

where Account is a class.
Does Account.this mean any current instance of class Account?

有帮助吗?

解决方案 2

Normally it is used inside of an inner class: It means the this instance of the outer Account class.

Writing this by itself will return the instance of the inner class, not the outer class.

其他提示

This would probably be from an inner class of Account.

class Account {
  class InnerAccount {
    ...
    synchronized(Account.this) {
    }
  }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top