a. Thread groups are deprecated and not recommended for use.
b. In my case, I only have access to spawned thread and I'd like to
know what other threads exist, that should include the main thread as
well. I have a feeling that it might be a security violation.
Thanks a lot.
>> I guess if you dont have a contention then dont use Hashtable as it
>> would slower the execution.
>
> Hmm. What is the difference in implementation of these datastructures?
Almost nothing.
> Isn't HashMap uses some sort Black tree and those get time isO( Log
> n)? Whereas in hashtable it is O(1)?
No HashMap is a hash table/map. TreeMap is a red-black tree
implementation. If you stick to declaring references as Map, you can
switch between the different implementations as you like.
HashMap is approximately O(1) in the normal case. However in the worst
case it is O(n).
>> You can always do this programmatically while spawning threads or use
>> ThreadGroup
> a. Thread groups are deprecated and not recommended for use.
ThreadGroup is not deprecated. It's generally not recommended, because
it isn't recommended to do that sort of thing.
> b. In my case, I only have access to spawned thread and I'd like to
> know what other threads exist, that should include the main thread as
> well. I have a feeling that it might be a security violation.
You should be alright if a SecurityManager is not set. If it does throw,
then that's because you're not allowed at that information, rather than
the particular approach you take.
If it's just for debugging, ThreadGroup should be fine, as is ctrl-\
(ctrl-break in Windows, IIRC) from the console, jdb or other debugger,
or the JVM JMX (java.lang.management) possibly remotely through the
likes of jstack (not Windows) and jconsole.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/