1

The output from WMIC:

C:\Users\fra>WMIC CPU Get DeviceID,NumberOfCores,NumberOfLogicalProcessors
DeviceID  NumberOfCores  NumberOfLogicalProcessors
CPU0      4              8

C:\Users\fra>

It tells me I have got 4 cores and 8 processors. In regard to developing Java applications, how many concurrent threads are effectively executed? If I start 32 threads that are long running tasks, will all of them execute concurrently?

The processor is:

Intel i7-4800MQ CPU @2.70GHz
3
  • 1
    You can only have 8 threads on your system but you should write your code to use as many threads as you have processors. Any attempt to launch more then 8 threads would result in the threads byeond 8 being queue by the OS.
    – Ramhound
    May 27, 2014 at 11:08
  • 3
    The way your question is phrased suggests you think each core has 8 processors. This is not the case. Each core has two logical processors, making total of eight logical processors for the CPU. May 27, 2014 at 11:09
  • @Ramhound I get your meaning... But I have dozens of threads running on the dual core I am using right now :D May 27, 2014 at 11:22

1 Answer 1

2

The short answer: Maybe and kind of.

Each core can not do more work than one thing at a time, or more than one thing per tick. The operating system however can schedule work for many processes per core per any unit larger than one tick. This is a simple way of looking at hyper-threading.

If an application has long wait periods, then 32 threads could easily be loaded into memory and run simultaneously with little to no performance impact, which I assume is really the question. If 32 computation intensive threads were created, the longer work cycles versus shorter wait cycles would void the illusion of simultaneous work.

Really, hopefully if 32 threads is your goal you have a reason for picking this number and it is dynamic for further down the road. One processor might handle 32 threads well, another may choke and in 5-10 years 32 threads may be less than one thread per physical core. Regardless, testing the application with 4, 8, 16, and 32 threads to see which completes the work fastest on your application would be best to see if the workload scales well to your goal of 32 threads.

2
  • 1
    The reason is that I want to run concurrent tests that will execute http requests concurrently. THe number 32 was because I was thinking 4 cores times 8 processors = 32. Is that reasonable assumption? The processor is Intel i7-4800MQ CPU @2.70GHz. I want to estimate the number of concurrent users the server can handle at any given time (approximately). May 27, 2014 at 11:07
  • 2
    @user3111525 No. You have 4 physical processors, each with hyperthreading or 2 virtual processors. 4 * 2 = 8 logical processor. You do not multiply cores by total logical processors. Again, test it for your usage though. HTTP request likely will have a long wait, so having extra idle threads running async might work out OK in this situation. May 27, 2014 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .