1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Problem in Multi-Threading implementation.

Discussion in 'Oracle Development General' started by Abhi_aec, Mar 16, 2015.

  1. Abhi_aec

    Abhi_aec Active Member

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    55
    Hi,

    I need to improve performance of one application, which is implementing Multi-Threading.
    My problem is:
    1. future.get(); is taking too much time.
    2. executor.shutdown(); also taking much time.
    Below is my piece of code code we are using below code:
    Code (Text):
    Map<String, List<? extends Object>> entirelist = null;
                                ExecutorService executor = Executors.newFixedThreadPool(maxThread);
                               
                                entirelist = manageCJObject.populateCS(cJGroup, load
                       
                        future = executor.submit(new CsThread(clDAO, entirelist, isUpdate, dbList));
                               
                         try {
                      if (future != null) {
                    long startTime = Calendar.getInstance().getTimeInMillis();
                    String result = future.get();
                    System.out.println("Total Time in future.get "+ (Calendar.getInstance().getTimeInMillis()-startTime));
                }
                long startTime1 = Calendar.getInstance().getTimeInMillis();
                executor.shutdown();
                executor.awaitTermination(
                        Constants.INT_VALUE_THIRTY,
                        TimeUnit.MINUTES);
                System.out.println("Total Time in exec shutdown "+ (Calendar.getInstance().getTimeInMillis()-startTime1));
            }
            catch (ExecutionException execp) {
                logger.error("Error dering Thread execution :: " + execp.getMessage());
                throw new CLException(execp.getMessage());

            }
    Kindly let me know how to improve performance. And what way we can provide any alternate of future.get() and executor.shutdown()