The problem is that checking the CPU usage is fairly misleading
if you are worried about contention. If your process takes up
100% of CPU and nothing else needs the resource, does it matter?
I would not want to sleep *unless* something else needs the
resource. Of course, there might be a good/easy way of checking
usage + contention, but I am unaware of any off the top of my
head.
On *nix you should just set the appropriate nice-ness and then
let the OS handle CPU scheduling. Not sure what you would do
for Windows--I assume OS X is the same as *nix for this context.
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at
http://www.jpmorgan.com/pages/disclosures/email.