1. First of all, how will you calculate the cpu usage in
Java? I think that it is not possible in pure java (please correct me if I am wrong). The only solution seems to write the cpu-calculating task in C language and use JNI to get the result.
2. If you are able to calculate cpu usage in Java (teach me too
then you can run two separate threads. One to display the bars showing percentage (in AWT/Swing) continuously, and the
thread other to calculate cpu-usage.