mercredi 5 août 2015

Impact of Daemon Thread Or Normal Thread When Application is Running in Development mode


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.

  1. Is it good to use Daemon Threads here ?
  2. Will System.exit(0) will be Useful here ?
  3. 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