Scheduler gets the configuration from the server through new single thread. But application continues to execute even when the scheduler is executing the config() to get the configuration from the server.
App{
XXXX;
XXXX;
try{
scheduler()
} catch(Exception e){
}
public void scheduler(){
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
Callable<Void> callable = new Callable<Void>() {
public Void call() throws Exception {
try {
config();
} finally {
service.schedule(this, TimeOut(), TimeUnit.SECONDS);
}
return null;
}
};
service.schedule(callable, 0, TimeUnit.SECONDS);
}
How to make the main thread wait until the single thread getting the config completes.