1.

Explain Thread Group. Why should we not use it?

Answer»

ThreadGroup is a class that is used to create multiple groups of THREADS in a single object. This group of threads is present in the form of three structures in which every THREAD group has a parent except the initial thread. Thread groups can contain other thread groups also. A thread is only allowed to have ACCESS to information about its own thread group, not other thread groups. 

PREVIOUSLY in the old version of Java, the only functionality that did not work without a thread group was uncaughtException( Thread t, Throwable e). But now in Java 5 versions, there is Thread.setUncaughtExceptionHandler(UncaughtExceptionHandler). So now even that works without thread groups and THEREFORE, there is no need to use thread groups.  

t1.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { System.out.println("exception occured:"+e.getMessage()); } };


Discussion

No Comment Found