hi,

I had a while loop in a run method, and in the while loop were a series of if stements. the series of if statments were in a try. my hope was if any if statement conked out it would catch the error, and continue the while loop ( the catch is in the while loop) and if there is more data it would try fresh and maybe that if statements routine if() { routine} wouldnt throw an exception. but what happens is if i do something wrong the whole run method stops doing anything. i was looking up an array at array[-1] by mistake in some cases. here is the code.

public void run()
	{
		int a=1;
	while(a==1)
	{
	try{
								

	newBoardData temp = new newBoardData();
	temp=gamequeue.poll();
	if(temp != null)
	{

					
// other if statements looking at temp.dg ==

if(temp.dg == 13 || temp.dg == 16 || temp.dg == 19)// 13 16 19result
{

							//writeToConsole("in dg 13 16 19 result");
							int gamenum=getGameBoard(temp.arg1);
						
// this line was my error. if gamenum == -1 dont want to do myboards[gamenum]!=null, should be next line if statmeent to check that if we know its not -1	
if(gamenum==-1 || myboards[gamenum]== null)
								return;
							myboards[gamenum].gameEnded(temp.arg1); // pass game number
							updateGameTabs("W", gamenum);
							repaintBoards(gamenum);
					}
}
	else
	{
	try {

	Thread.sleep(3);
	}
	catch(Exception e)
					{}
}// end no data


}// end try
catch(Exception e)
{}

} // end while
}// end run

I think i figured it out. my method is returning on error. so i leave the run. i put the series of if statements in anotehr method that is called from the while loop so it can return but continue the while loop.

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.