Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Makes no Sense!?!

Status
Not open for further replies.

scheenstra

Programmer
Feb 28, 2002
15
US
Hi, I'm having a very odd problem with some applets I have created. Most the time that i run them, they work just fine, but sometimes they freeze up. Is this a system problem or could it be something in the code. I would greatly appreciate any and all helpfull advice. Thanks.
 
'fraid you'll have to cough up quite a bit more information if you expect an answer...
 
The applets create supply and demand graphs, these graphs have both slider bars and small squares that are designed to be able to move around and therefore change the graph. This way people can see the effect the a certain change would have. The thing is that sometimes when i run them, the slider bars and squares freeze, and cannot be moved by the mouse. hopefully this helps. thanks again.
 
ARe these done using Swing or AWT? Are you using threads? Are you changing GUI components from other threads?

What browser are you using? Have you checked the memory usage of the browser or the process status (e.g. in NT) for the browser to make sure that things are locking up (100% CPU)?

How about submitting some of the code that may be causing the problem?
 
OK, first off these applets are done using AWT, The browser is Explorer 5.0 and the OS is Windows 2000 pro. concerning the code. This isn't my code, so i'm not exactly sure what the problem could be. however, what you said about possibly locking up at 100% cpu sounds like a strong possibility. I found the "Java Console" option in the "view" pulldown of explorer and the numbers seemed a little low, free memory ranged from 10,000 or so to 160,000. while Total memory ranged from 325,000 to 550,000. are these numbers where they should be, and if not, where can i allocate it some more memory. I also couldn't seem to find a CPU monitor in win.2000 to see what that was. to many years using win. 98. thanks again for all the help.
 
OK, I stopped spacing out and found the cpu usage screen. and, whenever i move the graph around the cpu trips out from 2 ore 3% all the way to 100%, so this seems like it is what is causing my problems. I'm just not sure on how to fix it.
 
RIght click on the task bar and select task manager. There you will find the cpu monitor.

The reason that I was asking about Swing/AWT is that Swing is inherantly thread unsafe. Many people make the mistake of creating multiple threads and having those threads interact with the Swing components--a sure prescription for deadlock and erratic program behavior.

Be interested to find out about the CPU utilization...
 
Well, i think we have a winner. I looked at the CPU usage again and everytime i moved the the graph around it would get deadlocked and the CPU would peg out to 100%. The system memory however varied vary little, moving from a normal 135,000 k to a max of 150,000 k or so on a machine that has 256 megs. Is there or fix for this or is a user with a slow CPU just out of luck. as far as Swing/AWT goes, like i said before this isn't code that i actually wrote, but their are no imports of any Swing componants and their are about 8 imports of AWT componants. Oh, by the way, i'm not sure about the processor speed of the computer that i'm using, but it is a Pentium 3, so i don't see why this simple operation would take the whole chip. thanks again meadandale.
 
here is some more mystery, i finally got one to lock up completly instead of just stalling out, and it locked up when the cpu hit 100%, but then the cpu returned to 1 or 2% and the graph still wouldn't move. i'm telling ya, it doesn't make much sense.
 
If the program is poorly written, it could be hanging up.

You see, when writing java gui components, all of your program code runs in the event handling thread. When you click a button and invoke an action listener, the code in the action listener happens in the same thread as the thread that responds to your gui components. If your actionlisteners have code that hangs, or is slow, you will notice that the gui components become sluggish or stop responding at all.

This is why the axiom of gui programmers in java is to write fast event handlers. If you need to do more intensive processing you need to spawn a new thread to do this so the gui thread is free to continue handling input.

IMHO, the applet you are using has some bad code that is blocking for some reason and when it does, it brings the whole works to a dead halt. Feel free to email me the class(es) and I can decompile them and see if I can find any probs. I may be able to 'fix' the code and return it to you or it may have significant flaws such that I would recommmend looking elsewhere for a solution.

Your call...

meadandale@hotmail.com.nospam

Regards,

Charles
 
Charles, I sent the classes and i just wanted to confirm that you recieved them, is your email address linked correctly above? what's with the .nospam or .nosp after the .com? is that a feature that i'm not aware of or was it a mistake? thanks. Alan
 
Nope, didn't receive them. To send me email, remove the .nospam suffix. I just don't want to post my unadulterated email in case someone tries to harvest this site for addies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top