This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Could you tell me how many threads can concurrently run on my machine. Following are some of the details I have, based on what google suggested.
1. When I go to device manager and click on Processors tab, I see 8 tabs. Screenshot is attached. So do I have an 8-core processor.
2. Also when I click on task manager-performance tab, I see 8 CPU history boxes in the CPU usage section. Screenshot attached.
That depends on your definition of "concurrently" and what kinds of threads you're talking about. Given the deep pipelines and multiple functional units of modern CPUs, an 8-core CPU will have many more than 8 instructions being worked on in parallel, probably closer to 80.
On the Java side, you can probably start hundreds (maybe thousands) of threads and have them all make progress without putting any one explicitly to sleep - the JVM will do that on its own. But a thread context switch takes many instructions to execute, both for OS-level threads and for Java threads, so the overhead of thread management will make this inefficient sooner rather than later.
Also keep in mind that the OS needs CPU time for its dozens of processes, and the JVM needs time for its own threads, so you will never get all 8 cores working on your application code.