Getting physical CPU usage in Java?

Discussion in 'Java' started by nooneinparticular314159@yahoo.com, Jul 15, 2009.

  1. Guest

    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!
     
    , Jul 15, 2009
    #1
    1. Advertising

  2. Oops...sorry about the duplicate posting. It didn't look like it had
    gone through the first time...
     
    nooneinparticular314159, Jul 15, 2009
    #2
    1. Advertising

  3. Lew Guest

    nooneinparticular314159 wrote:
    > 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.

    --
    Lew
     
    Lew, Jul 15, 2009
    #3
  4. Ok, but how do I measure CPU usage?

    > Don't use Google Groups.
    >
    > If you must use GG, don't use refresh after you post, use one of the links.
    >
    > --
    > Lew
     
    nooneinparticular314159, Jul 15, 2009
    #4
  5. Am Wed, 15 Jul 2009 09:21:52 +0100 schrieb bugbear:

    > nooneinparticular314159 wrote:
    >> Ok, but how do I measure CPU usage?

    >
    > 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
     
    Martin Demberger, Jul 15, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. harish

    getting CPU usage in windows 2000

    harish, Dec 6, 2003, in forum: C Programming
    Replies:
    2
    Views:
    522
    Mark McIntyre
    Dec 6, 2003
  2. hvt
    Replies:
    0
    Views:
    1,220
  3. hvt
    Replies:
    0
    Views:
    1,499
  4. Replies:
    9
    Views:
    2,065
    Arne Vajhøj
    Jul 20, 2009
  5. Joe Van Dyk
    Replies:
    5
    Views:
    274
Loading...

Share This Page