Results 1 to 5 of 5

Thread: Infinite loop

  1. #1
    jyde001 is offline Member
    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Default Infinite loop

    please am new to java programming and i run the applet program below but it seems it runs unending(infinite loop), and it is really slowing down my system Please how can i end(abort) it?.

    your timely assistance will be highly appreciated


    import java.awt.*;
    import java.util.*;

    public class Ouch extends java.applet.Applet {
    int debt = 683;
    int totalTime = 1;

    public void paint(Graphics screen) {
    screen.drawString (totalTime + " second's worth of debt is $"
    + (debt*totalTime), 5, 30);
    for (int i=0; i<500; i++);
    totalTime++;
    repaint();
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: Infinite loop

    Threads are free.
    Please don't hijack someone else's to ask your own question.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: Infinite loop

    In answer to yout question, repaint() calls paint() which enters your loop and then calls repaint()...which calls paint()...etc etc.
    So don't do that.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,256
    Rep Power
    19

    Default Re: Infinite loop

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    jyde001 is offline Member
    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Default Re: Infinite loop

    Thanks, i don't mean to hijack someones post. pls pardon me... back to your answer, does it mean that it don't have adverse effect on my system?

Similar Threads

  1. Infinite loop
    By F.S. in forum New To Java
    Replies: 3
    Last Post: 03-09-2012, 12:52 PM
  2. infinite loop
    By javapink in forum New To Java
    Replies: 19
    Last Post: 03-06-2011, 02:28 AM
  3. how to end infinite loop
    By search4survival in forum New To Java
    Replies: 14
    Last Post: 10-25-2010, 08:59 AM
  4. Infinite loop
    By jDennis79 in forum New To Java
    Replies: 7
    Last Post: 08-13-2010, 11:45 PM
  5. Infinite Loop
    By bosoxfan in forum New To Java
    Replies: 3
    Last Post: 02-22-2010, 01:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •