I have some code like this:
package somepackage.somefolder;
public class MyClass {
public MyClass () {
new Thread() {
public void run() {
SomeOtherClass something = new SomeOtherClass(REFERENCE-TO-MyClass-NEEDED!!!);
}
}
}
public someFunction(){
//do stuff...
}
}
package somepackage.someOtherfolder;
public class SomeOtherClass {
public SomeOtherClass (MyClass mc) {
mc.someFunction();
}
}
How to send reference of the actual instance of MyClass to the other class so it could access MyClass someFunction()?
If I call it directly like:
SomeOtherClass something = new SomeOtherClass (this);
It points to Thread itself where I need it to point to the parent class it was started from, that is MyClass.
I cannot reference it as MyClass mc = new MyClass
inside SomeOtherClass as it would create new instance of the class.