I have the below timed task
:
static TimerTask timedTask = new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("timed task");
}
};
//main method
main(...) {
Timer timer = new Timer();
timer.schedule(timedTask, (long) logfile.getFileHash().get(1).getTimeStampInMilli());
}
what I want to do is, to create a class that exteds TimerTask
so that I can create a new timerTask
when ever i want. but the problem is when i create the class as follows:
class TimerTask2 extends TimerTask {
@Override
public void run() {
// TODO Auto-generated method stub
}
}
the line
timer.schedule(new TimerTask2(), (long) logfile.getFileHash().get(i).getTimeStampInMilli());
is higlighted by ecipse and says:
No enclosing instance of type File_IO is accessible. Must qualify the allocation with an enclosing instance of type File_IO (e.g. x.new A() where x is an instance of File_IO).
i tried to qualify te class instance with the main class name but also it did not work.
kindly please provide suggestions for that.