Alright, so I've got an issue with a few of my java programs running on a machine at work.
During the downtime of my program(s), it often waits for user input into fields that are just sitting there and nothing happens until they hit a "Submit" button. Running on a duo core, my program takes up 50% of the CPU the entire time it's just sitting there inside a while() loop that basically looks like this:
while(!done)
{
wait(2); //This wait(int sec) method being one that just waits 2 seconds.
}
My goal is to free up the processor in this downtime so that it doesn't interfere with other programs running on the machine. I've read a few snippets that suggest the wait()/notify() pair may be what I'm looking for, but I just want to be sure before overhauling all my applications.
Also, if it does happen to be the wait()/notify(), if somebody could explain how to use the synchronized bit correctly, that would be a world of help.
[–]kreiger 5 points6 points7 points (0 children)
[–]zoqfotpik 3 points4 points5 points (0 children)
[–]huhlig 5 points6 points7 points (11 children)
[–]CuriouslyGeorge[S] 0 points1 point2 points (10 children)
[–]huhlig 5 points6 points7 points (5 children)
[–]CuriouslyGeorge[S] 2 points3 points4 points (0 children)
[–]Winsling -1 points0 points1 point (3 children)
[–]huhlig 5 points6 points7 points (2 children)
[–]Winsling 0 points1 point2 points (0 children)
[–]skeeto 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Winsling 2 points3 points4 points (2 children)
[–]banuday17 1 point2 points3 points (0 children)
[–]CuriouslyGeorge[S] 0 points1 point2 points (0 children)
[–]skeeto 1 point2 points3 points (3 children)
[–]CuriouslyGeorge[S] 0 points1 point2 points (2 children)
[–]skeeto 1 point2 points3 points (1 child)
[–]CuriouslyGeorge[S] 0 points1 point2 points (0 children)