Hi!
I have implemented the following class which keeps track of the time needed to execute an algorithm
public class MyTimer extends Thread{
long timeElapsed = 0;
public MyTimer(String parameters){
//initilise staff
}
pubic void run(){
long startTime = System.currentTimeMillis();
//DO SOME THINGS THAT TAKE TIME
timeElapsed = System.currentTimeMillis() - startTime;
System.out.println("time elapsed = " + timeElapsed");
}
}
Some times the MyTimer do takes really a lot of time, so i would like to create another class to contol it. If the MyTimer hasn't finished in 30 sec then i would like the stop the thread and restart it with new parameters. if it finishes in less than 30 sec then i would like to be able to store the timeElapsed and restart the MyTimer again. I though that this would be simple but i have messed with thread pools timeCountLathces and monitor exceptions..... So, is there any way i can do it work? The alternative solution is to run my 500 tests one by one manually....
Thank you in advance