User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030624 Netscape/7.1
Hello:
I have several questions:
We have an application that is using reflection to load a method and
then execute it. From the parent thread, we use the following code
snippet to get a list of the threads BEFORE we call load and execute the
class and the target method:
//Initially assign topLevel to null and get the current group
ThreadGroup topLevel = null;
ThreadGroup tg = Thread.currentThread ().getThreadGroup();
//Parse up the thread "tree" to get the toplevel thread,
which will
//exist when no parent is to be found and topLevel = null;
while (tg != null)
{
topLevel = tg;
tg = tg.getParent ();
}
//Enumerate on all the threads, create strings, and make a
message to
//send to the UI.
if (topLevel != null)
{
Thread [] threads = new Thread [topLevel.activeCount ()];
msg = new String[topLevel.activeCount () + 1];
//Create the initial message
msg[0] = "\n\n Currently running threads: \n";
int nthreads = topLevel.enumerate (threads);
for (int i = 0; i < nthreads; i++)
msg[i+1] = new String(" Name: " + threads
[i].getName() + ", " +
"Thread Group: " +
threads[i].getThreadGroup().getName() + ", " +
"Priority: " +
threads[i].getPriority() + ", " +
"Daemon: " + threads [i].isDaemon
() + "\n");
If the method we launch creates another thread within it, I would like
to be able to list that thread and any other threads it may launch as
well. I assumed that if we used the same code from withing the thread
launched in the loaded class/launched method it would produce a list of
more threads....namely all the threads etc it has generated itself PLUS
all of those above. Instead what we get is the exact same list.
Does anyone know why this is ? Would it possibly be caused by the fact
the method is static? Also, does anyone know if there is a way that the
method that loads the class and launches the method can "parse into" the
newly launched method and obtain a list of all it's threads without
putting any of this thread listing code into the method?
Thanks in advance.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden