I found out that 2 threads are optimum in this case. I tried playing around with number of threads using the variables
numThreads = 2
executor.setCorePoolSize(numThreads);
executor.setMaxPoolSize(numThreads);
When I kept the numThreads to 4, (maybe due to i/o bottle neck or due to number of cores in my pc being 2), the response time was worse compared to the synchronous code. keeping it as 2 made the asynchronous implementation fast enough to beat get lower response time compared t o the synchronous case