Hi, I have been staring at the screen so long trying to figure out this problem, that I now have a headache. I have included 4 snipets of code which could possible have have something to do with the problem.

Declaration of Variables Snipet:

The Initialization Code Snipet (Included within the init() method):Code:double[] TRP=new double [100000], PRP=new double [100000]; int[] E1=new int[100000], E2=new int[100000], E3=new int[100000], I1=new int[100000], I2=new int[100000], I3=new int[100000];

Some code that does stuff (is looped with a timer of zero delay):Code:for (int i=0; i<100000; i++){ E1[i]=-1; E2[i]=-1; E3[i]=-1; I1[i]=-1; I2[i]=-1; I3[i]=-1; PRP[i]=70; TRP[i]=70; }

The Problem Code:Code:int Etemp=-1, Itemp=-1; for (int i=0; i<TRP.length; i++){ if (i==0){ if (PRP[i]<PRP[i+1] && PRP[i]<70){ if (Etemp!=-1){E1[Etemp]=i; E1[i]=100000; Etemp=i; } if (Etemp==-1){Etemp=i; E1[0]=Etemp; E1[i]=100000; } } if (PRP[i]>PRP[i+1] && PRP[i]>70){ if (Itemp!=-1){I1[Itemp]=i; I1[i]=100000; Itemp=i; } if (Itemp==-1){Itemp=i; I1[0]=Itemp; I1[i]=100000; } } } else if (i==99999){ if (PRP[i]<PRP[i-1] && PRP[i]<70){ if (Etemp!=-1){E1[Etemp]=i; E1[i-1]=Etemp; E1[i]=100000; Etemp=i; } if (Etemp==-1){Etemp=i; E1[0]=Etemp; E1[i]=100000; } } if (PRP[i]>PRP[i-1] && PRP[i]>70){ if (Itemp!=-1){I1[Itemp]=i; I1[i-1]=Itemp; I1[i]=100000; Itemp=i; } if (Itemp==-1){Itemp=i; I1[0]=Itemp; I1[i]=100000; } } } else { if (PRP[i]<PRP[i-1] && PRP[i]<PRP[i+1] && PRP[i]<70){ if (Etemp!=-1){E1[Etemp]=i; E1[i-1]=Etemp; E1[i]=100000; Etemp=i; } if (Etemp==-1){Etemp=i; E1[0]=Etemp; E1[i]=100000; } } if (PRP[i]>PRP[i-1] && PRP[i]>PRP[i+1] && PRP[i]>70){ if (Itemp!=-1){I1[Itemp]=i; I1[i-1]=Itemp; I1[i]=100000; Itemp=i; } if (Itemp==-1){Itemp=i; I1[0]=Itemp; I1[i]=100000; } } } }

OK, so the problem is that it seems that when ever j becomes 99999 (as far as I can tell), the while loop break conditional is never met and so the while loop proceeds to an infinite loop. I have no idea why, especially since for a while in the begenning, the break statement is met with no problems, its just that as the program keeps looping with the timer, the while loop eventually reaches an infinite loop as j seems to become 99999.Code:Etemp=-1; Itemp=-1; int j=E1[0],k=I1[0]; boolean Eloop=true,Iloop=true; while (j>-1){ //some code that does stuff, not an issue because its ignored being stated as a comment j=E1[j]; if (j==100000)break; }

If extra code is required, let me know, and I would of course really appreciate it if someone could help me with this problem. I know its asking a lot, so thanks a bunch in advance