Question: How do we terminate a `Thread` or `ThreadGroup` instance by it's name ?

Answer: 
Something like this

```
    Thread[] a = new Thread[1000];
    int n = Thread.enumerate(a);
    for (int i = 0; i < n; i++) {
        if (a[i].getName().equals(name)) {
            a[i].interrupt();
            break;
        }
    }

```

though interrupt() does not terminate the thread, stop() does (though deprecated)
It depends on what do you mean when you say "terminate". 

But first tip is that you have to get a list of all threads to terminate. Use `Thread.getThreads()` to do this. You can filter threads by their group if needed. 

Now, how to stop the thread? There are 2 ways.

1. call `stop()` method. It is deprecated and you should never use it because it might cause system to enter inconsistent state. However, if you *really* want ... this method is still supported.
2. Every thread should support shutdown mechanism, i.e. a "protocol" that can be used to signal thread to exit its `run()` method. If all threads are yours you can make them to implement your own interface (e.g. `Terminatable`) with method `terminate()` that will change value of flag and cause thread to exit. In this case your code that terminates threads should iterate over threads, check that thread should be terminated and that it implements interface `Terminatable`, cast to it and call its `terminate()` method.