posted 24 years ago
The NullPointerException message tells you that it originates from line 55 of your file. This is really useful information, and much easier for you to find than for us. So whe you post an error like this, it's a good idea to point out for us exactly which line is throwing the error. By inspection though, I'm pretty sure it's the line
<pre> System.out.println(indent +" \""+aThread.getName()+"\"");</pre>
The reason is that aThread is null - at least, it may be null. Note that the ThreadGroup activeGroupCount() method only returns an estimate of the number of active groups - which means the number of groups in the array after enumerate() is called, may be different. And if enumerate returns fewer groups than the original estimate, then your array will have nulls in the remaining slots. Instead, save the return value from enumerate() to find out how many groups were actually returned, and use this to control your for loop through the array. Or, check each element to see if it's null before you access it.
"I'm not back." - Bill Harding, Twister