Thanks for the replies guys... that is exactly what I am doing. Unfortunately the solutions above, while making some sense are a little confusing to me (quite the programming nub unfortunately).
The client is very simple ( and the server likewise) there is only one socket connection (ie one host:port )
right now I have methods checking for network input and/or keyboard input in the same while loop... in fact...
User Profile
Collapse
-
There are several objects... mainly objects used to deal with network connectivity and IO.
However the program is basically one recurring loop (until the user quits the chat client). This is unavoidable since it must be constantly looping and dealing with asynchronous network input as well as user keyboard input...
I am guessing then it is this loop that causes the high CPU usage? Are there any strategies for minimizing...Leave a comment:
-
why does my Java console program take up so much CPU time?
I wrote a very simple instant messenger client but, unfortunately, since I am still a relatively new programmer I am not familiar with what causes a program to eat up so much CPU time. Currently at runtime my program takes up 11mb in memory and 90-100% cpu usage!!
Without posting all the code, what factors contribute to cpu usage? I am not really sure what information would help others troubleshoot my program, so please let me know... -
can sizeof( <array> ) work in a function body?
I wanted to write a function to take the tedium out of dynamically determining the total number of elements in an array.
Within the main method this is easy as I simply use:
However I am running into an annoying problem when trying to pass an array reference to a function that is suppossed to return the same value as the above would.Code:sizeof( <array name> ) / sizeof( <array type> )
my function...
No activity results to display
Show More
Leave a comment: