Home » Java ThreadGroup setDaemon() method with Examples

Java ThreadGroup setDaemon() method with Examples

by Online Tutorials Library

Java ThreadGroup setDaemon() method

The setDaemon() method of ThreadGroup class tests if the thread group is a daemon thread group.

Syntax:

Parameter:

daemon: If true, marks the thread group as a daemon thread group; otherwise, marks the thread group as normal.

Exception:

SecurityException: If the current thread cannot modify the thread group.

Example

Test it Now

Output:

Is Parent thread a daemon threadGroup? true  Is Child thread a daemon threadGroup? false  Thread-1 completed executing  Thread-2 completed executing  

You may also like