Re: Inconsistent CPU usage
- From: RedGrittyBrick <RedGrittyBrick@xxxxxxxxxxxxx>
- Date: Wed, 30 Apr 2008 16:12:20 +0100
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 displayedwhile(!pW.isFinished){;}; // programmatic block to put up screen
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
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
.
- References:
- Inconsistent CPU usage
- From: Elliot
- Re: Inconsistent CPU usage
- From: Knute Johnson
- Re: Inconsistent CPU usage
- From: Elliot
- Inconsistent CPU usage
- Prev by Date: Re: Help! Where's my UIManager
- Next by Date: JAAS configuration
- Previous by thread: Re: Inconsistent CPU usage
- Next by thread: Re: Inconsistent CPU usage
- Index(es):
Relevant Pages
|