To get the no. of cores available on a system i.e. including physical cores and virtual cores.
Physical cores are the no. of cores available on your system.
Virtual cores includes the threading capability of your processor cores.
Lets say each of your core is capable of executing two threads at a time(this is called hyper-threading) then your virtual cores will be “2 x no. of cores”.
To get the no. of cores in java you use the following:
This is the no. of virtual cores and as mentioned above will be “2 x no. of cores”.