Is there a way to know CPU usage / idle?

For an EMX or G120, is there a way to determine the load or idle on the CPU ?
I have a couple threads in my application, and I’d like to know what’s the general load on the cpu (a bit like the taskmanager in windows).

Maybe the task scheduler that handles the threads in the VM has this information ?

I always put some Thread.Sleep() in the while(…) from each threads, but still, I have no idea how much headroom I have left to program more stuff without having a significant impact on the different threads.

There is no standard way to do this.

You can develop a thread which execute something n times and determines how long it takes and prints out the results. You run this thread standalone, to calibrate it. You then add it to your application, and look at the results. This would give you a relative comparison of load.

You could also try setting the load determination thread to low priority, to minimize it impact on the application.