I am observing a very strange problem in a java client server application. I am sending following Runnable objects to the server at 80 requests per second. The thread pool keeps pool size equal to the request rate i.e. approximately 80 threads in the pool. My laptop is intel Core i5-3230M dual core(Windows show me 4 processor). Strange thing is that the Throughput(jos completed per second) is also 80. I could not understand this. How 4 processors and 80 threads are completing 80 jobs of 100 milliseconds in one second ? That is:
Processors=4
Request rate=80
Thread pool size=80
Each job service time=100milliseconds.
Throughput=80 How?
I was expecting throughput=40 because each processor should approximately complete 10 jobs in 1 second so 4 processors should give throughput=40 but it is 80 ? Laptop specification link says
Also, the cores can handle up to four simultaneous threads, which improves the performance and resource-utilization of the CPU.
Does this means 8 threads can run at the same time b 2 cores?
public class CpuBoundJob implements Runnable {
public void run() {
long startTime = System.nanoTime();
while ((System.nanoTime() - startTime) < (100)*1000000L) {}
}
}