Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out how many threads my application is running?

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!

like image 781
user1192403 Avatar asked May 03 '12 22:05

user1192403


People also ask

How can I tell how many threads are running?

Open Task Manager (press Ctrl+Shift+Esc) Select Performance tab. Look for Cores and Logical Processors (Threads)

How many threads are running Java application?

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.


2 Answers

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.

like image 56
Darin Dimitrov Avatar answered Oct 16 '22 12:10

Darin Dimitrov


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

enter image description here

like image 2
Legends Avatar answered Oct 16 '22 12:10

Legends