Getting physical CPU usage in Java?

  • Thread starter nooneinparticular314159
  • Start date
N

nooneinparticular314159

I'd like to be able to determine what the total CPU usage is on a
system using a Java program. (for those of you familiar with the Unix
program Top, it's the same idea. I want to be able to poll the system
to see how much CPU time is being used right now.)

Is there an easy way to do this? Is the method platform
indepdendent? ie. Since Java can run on any platform, will the
solution also work on any platform?

Thanks!
 
N

nooneinparticular314159

Oops...sorry about the duplicate posting. It didn't look like it had
gone through the first time...
 
L

Lew

nooneinparticular314159 said:
Oops...sorry about the duplicate posting. It didn't look like it had
gone through the first time...

Don't use Google Groups.

If you must use GG, don't use refresh after you post, use one of the links.
 
M

Martin Demberger

Am Wed, 15 Jul 2009 09:21:52 +0100 schrieb bugbear:
I use top :)

(Although, on a modern, multi-core, multi cpu system,
CPU usage is nowhere near the simple concept it used to be)

In truth, given that Java is designed to be
system-blind, it would seem that the level
of access required for what you want is almost
a direct contradiction of Java's design goals.

BugBear

Hi BugBear,
you can use the ThreadMXBean. For an example see
http://www.javaspecialists.eu/archive/Issue135.html

cu
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top