[kaffe] ColdFire- ThreadGroup.add() dead-loop at init

Dalibor Topic robilad@yahoo.com
Wed May 21 07:49:01 2003


Czesc Jan,

--- Jan Sobota <hermez@microtech.softax.com.pl> wrote:
> the problem:
>  the following code in java.lang.ThreadGroup class generates never ending
> loop.
> 
> 	synchronized void add(Thread thread) {
> 		int i;
> 		nthreads++;
> 		if (threads == null) {
> 			threads = new Thread[1];
> 		}
> 
> 		// [THIS LOOP RUNS AND NEVER ENDS]
> 	        for (i = 0; i < threads.length; i++) {
> 			[..]
> 		}
> 		[..]
> 	}

try evaluating thread.length only once, while it doesn't fix your bug you
should be able to get past the loop:

int length = threads.length;
for (i = 0; i < length; i++) { .... }

cheers,
dalibor topic

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com