public class GetCurrentPrice implements Runnable{
public void run(){
// some business logic
}
}
public class Main{
public static void main(){
GetCurrentPrice gcp = new GetCurrentPrice();
Thread t = new Thread(gcp);
while(true){
t.start();
//once this thread execution is complete, restart this thread.
}
}
}
This throws java.lang.IllegalThreadStateException. What i am trying to achieve is, run this thread once, wait for it to complete, once it is complete, run this thread again.