Java Reference
In-Depth Information
if (showInterior)
{
return node;
}
}
return nextDescendant();
}
protected Object nextDescendant()
{
while (true)
{
if (subiterator != null)
{
if (subiterator.hasNext())
{
return subiterator.next();
}
}
if (!children.hasNext())
{
return null;
}
Iterable i = (Iterable) children.next();
if (!visited.contains(i))
{
subiterator = i.iterator(visited);
subiterator.setShowInterior(showInterior);
}
}
}
SOLUTION 28.4
The go() routine launches a new thread that can wake up at any time. If you run the code
repeatedly, you may get varying results, depending on your compiler, your virtual machine,
and the environment in which you are running. The output indicates that in the given run,
the go() method retains control through three iterations, printing the list from index 0 to 2:
Mixer1201
ShellAssembler1301
StarPress1401
At this point, the second thread wakes up and places "Fuser1101" at the beginning of
thelist, bumping all the other machine names down one slot. In particular,
"StarPress1401" moves from index 2 to index 3.
When the primary thread regains control, the go() method prints the remainder of the list,
from index 3 to the end:
StarPress1401
UnloadBuffer1501
Search WWH ::




Custom Search