Unpredictable behavior in Java Thread Pool while capturing response for multiple threads
up vote
0
down vote
favorite
I am trying to add 10 records to different server with the help of thread pool and waiting for response to get the information added on server side, but when I execute the code at my end I am getting same response for few threads, but data stored at server end are unique values per record. ExecutorService threadPool = Executors.newFixedThreadPool(10); List<Future<Employee>> listOfEmployee = new ArrayList<Future<Employee>>(); List<Employee> employeeList = new ArrayList<Employee>(); for(int i=0;i<10;i++) { listOfEmployee.add(threadPool.submit(new Callable<Employee>() { @Override public Employee call() { return employee.add(); } })); } threadPool.shutdown(); threadPool.awaitTermination(100,TimeUn