At any given time, the processor will start the number of threads equal to the number of cores contained. This means that in a uniprocessor system at any given time only one thread (or thread) is running.
However, processors do not start each thread one by one, but quickly switch between multiple threads to simulate simultaneous execution. If this were not so, not to mention creating multiple threads, you wonβt even be able to run multiple applications.
A java thread (compared to processor instructions) is a very high level of abstraction of a set of instructions for the processor to process. When it goes to the processor level, there is no guarantee which threads will run on which core at any given time. But, given that processors quickly switch between these threads, it is theoretically possible to create an infinite number of threads, albeit at the cost of performance.
If you think about it, a modern computer has thousands of threads working simultaneously (combining all applications), having only 1 ~ 16 (typical case) number of cores. Without this task switch, nothing will work.
If you are optimizing your application, you should consider the number of threads you need at your fingertips, not the underlying architecture. The performance gain from parallelism should be balanced against the increase in thread execution overhead. Since each machine is different, each runtime is different from the others, it is impractical to work out a certain number of gold threads (however, the ball can be estimated by benchmarking and viewing the number of cores).
initramfs
source share