Reputation: 18251
Hello, I have runnable inner class. Outer class waits inner class notification. After notification is done I need outer class to read some inner class object state params. For this reason I make sleep inner class and wait for outer class read parameters and send notification. For this reason I need synchronise on outer class object.
How to get outer class object from inner class?
Upvotes: 1
Views: 94
Reputation: 41281
If outer class is called Outer
and inner class is Outer.Inner
, then you can get your outer instance with:
Outer.this
when in the inner scope.
You can call methods and access fields this way, but you cannot assign to Outer.this.
Upvotes: 3