What is the impact for using Daemon threads or Normal Threads in my Play Application. I am having some Akka Scheduler, and Quarts Schedulers. These are being start When Application start. My App is running in Dev mode, and whenever i made changes to my Source Code, it restart's / Auto Reload application that Cause Thread DeadLock. What is the best way to stopping these Threads.
- Is it good to use Daemon Threads here ?
- Will System.exit(0) will be Useful here ?
- Is any Other way to stopping these running/waiting threads that are sleeping for a particular time in scheduling ?
I'm trying to do something like:
Akka.system().scheduler().schedule(Duration.create(2000, TimeUnit.MILLISECONDS), Duration.create(60000, TimeUnit.MILLISECONDS),
() -> {
String url = Play.application().configuration().getString("localloadbalancer.ip");
url = url + "initCallOut";
Logger.info("Calling initcall from global.java::" + url);
HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(url);
try {
HttpResponse response = client.execute(request);
int statusCode = response.getStatusLine().getStatusCode();
Logger.info("Status Code::" + statusCode);
if (statusCode == 200) {
// Do stuff here
} else {
// retry
}
} catch (IOException ex) {
Logger.error("Error in Initcall::" + ex.getMessage());
}
}, Akka.system().dispatcher());
// Quartz scheduler starting here
try {
QuartzScheduler.startScheduler();
}
catch (Exception ex){
System.out.println("Scheduler Exception::"+ex.getMessage());
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire