Let me try...
1. Why do we create ThreadGroup?
ThreadGroups are logical ways of grouping related threads. Every threads belong to a threadgroup. After grouping the threads, you can perform various actions on
all the threads involved in the group. If your program is heavily multi-threaded, then ThreadGroups might offer you better manageability and some kind of cleaner design.
2. Can�t we have both type of threads(demon/non-demon) in simple a ThreadGroup?
Absolutely you can.
3. When it does not exist?
ThreadGroups always exist. There is atleast one threadgroup called main, which happens to be the default threadgroup the threads belong to.
4. Any other thing do u think I should know please let me know about simple ThreadGroup.
Just look at them as collection of threads with "group methods".
Java API
Doc offers more explanation on ThreadGroups, however you are not required to know them for
SCJP.
5. Why do we create Demon ThreadGroup? ( may be this is related to the answer of question
#2 because if we can�t have both type of threads in simple ThreadGroup then we may need to create demon ThreadGroup. Just guessing.)
You can have a ThreadGroup with both daemon and user threads. If you want to mark
all the threads in a ThreadGroup as daemon, then you can use ThreadGroup.setDaemon(true);.
The documentation says
A daemon thread group is automatically destroyed when its last thread is stopped or its last thread group is destroyed.. I have to confess I have never used them, and I don't know if there is any compelling reason to use them.
6. Why does it contain both types of thread ? if simple ThreadGroup can�t have demon threads.
See answer to question 5. Perhaps it was a design decision to allow both non-daemon and daemon threads to belong to the same group. After all, it is just about grouping of threads, nothing more!
Hope this helps. Again, you are NOT REQUIRED TO KNOW ABOUT THREAD GROUPS FOR SCJP EXAM.
Ajith