Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

thread ID

Thread view: 
sconeek@gmail.com - 06 Jun 2006 02:00 GMT
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.
Eric Sosman - 06 Jun 2006 03:31 GMT
> 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?

Signature

Eric Sosman
esosman@acm-dot-org.invalid

sconeek@gmail.com - 06 Jun 2006 03:36 GMT
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.
lakshmi2510@gmail.com - 06 Jun 2006 08:06 GMT
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
Eric Sosman - 06 Jun 2006 13:12 GMT
    (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!

Signature

Eric Sosman
esosman@acm-dot-org.invalid



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.