Re: Inconsistent CPU usage



Elliot wrote:
On Apr 29, 5:46 pm, Knute Johnson <nos...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Elliot wrote:

Our Java Swing application uses sockets to communicate with a backend
Cobol database application. On 10% of the machines where the
application is running CPU usage goes to 100% at startup. On the
other 90% of the machines CPU usage is around 50%.
....
Perhaps the coding is part of the problem. A login screen is displayed
at the start of the application. In order to get the application to
stop and wait for user input the following line of code was used.
while(!pW.isFinished){;}; // programmatic block to put up screen

while(!pW.isFinished){;}; // programmatic block to put up screen

If the rest of your code looks at all like this, I'm surprised it runs
at all. You just cannot do this with Java and expect anything to work.


Knute - not really a helpful comment. How about pointing people in the
right direction?

Without seeing the rest of the code it is hard to be more specifically helpful. Not since the days of single tasking DOS has it been sensible to burn CPU cycles in a tight loop as a method of waiting.

With a Swing application you should never need to do this, the whole thing should by default be event driven.

e.g.
String pw = JOptionPane.showInputDialog(frame, "Enter Password");
new SocketyThing().start(pw);

The second statement won't be run until the first statement has been completed (by user pressing "OK").

A more realistic example would put SocketyThing().start(pw) into a SwingWorker - still no need for explicit waiting or signalling.

HTH.

--
RGB
.



Relevant Pages

  • Re: Taskmgr missing user names
    ... Where are you seeing the 99% CPU usage? ... > Also on these machines I have noticed that all the ... > fresh install of windows, so can anyone enlighten me on ... Outgoing mail is certified Virus Free. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Taskmgr missing user names
    ... windows XP pro and home, are running at 99% CPU usage, ... with a System Idle process of 99% too. ... Also on these machines I have noticed that all the ... fresh install of windows, so can anyone enlighten me on ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Whats using my CPU?
    ... So, you want to say, that if you have network connection, ... High CPU usage can also be explained by ... if I disconnect then the CPU usage peaks drop to less than 5%. ... don't see similar on any other machines. ...
    (microsoft.public.security.virus)
  • Re: VB6/Distinct Intelliterm screen scraping/painting
    ... apps using iterm32.exe of Distinct Intelliterm, ... noticed that the CPU usage on our production ... machines goes to as high as 100% during the screen scraping/painting ...
    (microsoft.public.vb.general.discussion)
  • Re: Whats using my CPU?
    ... The broadband connection is normally constant but I have just noticed that ... if I disconnect then the CPU usage peaks drop to less than 5%. ... don't see similar on any other machines. ... If I disconnect from the internet there is CPU usage at the same time ...
    (microsoft.public.security.virus)