I'm trying to find out how many threads my application is running in order to make a live graph of the performance. Can you point me in the right direction or provide a code example? Thanks!
Open Task Manager (press Ctrl+Shift+Esc) Select Performance tab. Look for Cores and Logical Processors (Threads)
All Java programs have at least one thread, known as the main thread, which is created by the Java Virtual Machine (JVM) at the program's start, when the main() method is invoked.
You may take a look at the Threads property of the current process:
System.Diagnostics.Process.GetCurrentProcess().Threads
Of course this includes unmanaged threads as well.
If you want to see only Managed Threads:
When you debug your application from Visual Studio you could also check out the Threads
and Parallel Stacks
window,
which can be found in the menu under Debug -> Windows
You can see the Thread-Count
(marked green) in the top Threads
window in the picture below
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With