In a class, I have a main method and temp method and I'm calling the temp method from main method but after 20 seconds I want to stop these method execution and start again to call temp method.
I have tried to use thread in the code but it won't work.
public static void main(){
temp();
}
public void temp(){
// here is my code which takes some time more than 20 second to
// so i want to stop these method execution and call again temp method
}