I have a very simple program which uses ExecutorService.
I have set the no. of threads to 4, but the time taken is same as that set to 2.
Below is my code:
public class Test {
     private static final Logger LOGGER = Logger.getLogger("./sample1.log");
    @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Throwable {
        ExecutorService service = Executors.newFixedThreadPool(4);
        Future<String> resultFirst = service.submit(new FirstRequest());
        Future<String> resultSecond = service.submit(new SecondRequest());
        Future<String> resultThird = service.submit(new ThirdRequest());
        Future<String> resultFourth = service.submit(new FourthRequest());
        String temp1 = resultSecond.get();
        temp1 = temp1.replace("Users", "UsersAppend1");
        String temp2 = resultThird.get();
        temp2 = temp2.replace("Users", "UsersAppend2");
        String temp3 = resultFourth.get();
        temp3 = temp3.replace("Users", "UsersAppend3");
        //System.out.println(resultFirst.get() + temp1 + temp2 + temp3);
        //LOGGER.info("Logger Name: "+LOGGER.getName());
        LOGGER.info(resultFirst.get() + temp1 + temp2 + temp3);
        service.shutdownNow();
        service.awaitTermination(10, TimeUnit.SECONDS);
        System.exit(0);
        }
}
Here FirstRequest, SecondRequest, ThirdRequest and FourthRequest are different classes which calls another class which is common to all.
I have created distinct objects for the common class so I don't think it's a case of deadlock/Starvation.
 
     
     
     
    