thread ID

S

sconeek

hi all,
how can i test if multiple threads of the same process are running, and
if found kill rest and run only one. i am finding that i am running
multiple threads and would like to kill rest except any one. any help
guys.
 
E

Eric Sosman

hi all,
how can i test if multiple threads of the same process are running, and
if found kill rest and run only one. i am finding that i am running
multiple threads and would like to kill rest except any one. any help
guys.

This seems a silly thing to want to do. Do you want to
kill the garbage collector's thread(s)? The finalizer thread?
The Swing event dispatching thread? A thread you've never
heard of that is part of the implementation of a class your
program relies on? Are you planning to have your thalamus
removed simply because you don't know what it does?
 
S

sconeek

i dont think so. there is no point in running multiple threads of a
process, if you dont need them. finding them and not running them is
the best thing in my view anyways.
 
L

lakshmi2510

Correct.... Dont spawn unnecessary threads and run into the overhead of
synch problems!! What context are you exactly trying to kill threads ?
U could probably monitor the number of threads u are spawning using
some static variable and shutdown the thread based on that count and
decrement the counter
 
E

Eric Sosman

(Please learn to quote enough context so that a message
can stand alone and still make sense. For those who may not
have seen the beginning of the thread, sconeek asked how to
kill all his program's threads except one, and I offered the
opinion that such an action would be both silly and dangerous.
We now resume our story ...)

i dont think so. there is no point in running multiple threads of a
process, if you dont need them. finding them and not running them is
the best thing in my view anyways.

Well, then, I suggest you perform the experiment for yourself.
Launch a Java program that will run for a fairly long time, and
kill off the "unnecessary" threads with system-specific ad-hoc
methods -- for example, maybe you can run the JVM under control
of a debugger and use the debugger's commands to nail the threads.
If the experiment is a success, you can then go on to look for
more convenient ways to arrange the assassinations. Good luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top