I'm using this standard constructor:
new Thread(myRunnable);
where myRunnable is custom object with Runnable interface.
During the thread process I need to access to that runnable object (to tell the process status and progress), how can I do?
If my object would be a Thread I would use:
(MyThread) Thread.getCurrentThread()
but with runnable passed as parameter I can not get that.
EDIT
This is my code structure:
public abstract class ProgressThread{
private float progress; //... progress getter, setter...
}
public class MyRunnable extends ProgressThread implements Runnable{
public void run(){
//starting processes...
Job1 j1=new Job1().do();
Job1 j2=new Job2().do();
}
private class Job1(){
for(int i=0;i<10;i++){
// do something
float progress=i/10;
// set job progress in thread
Thread.getCurrentThread().getRUNNABLE().setProgress(progress);
}
}
}
This is why i need getRUNNABLE() method (or a workaround!). Thanks.