destroy()
Java Thread destroy() method
Last Updated : 17 Mar 2025
The destroy() method of thread class is used to destroy the thread group and all of its subgroups. The thread group must be empty, indicating that all threads that had been in the thread group have since stopped.
Syntax
Return
It doesn't return any value.
Exception
IllegalThreadStateException: This exception throws if the thread group is not empty or if the thread group has already been destroyed.
SecurityException: If the current thread cannot modify this thread group.
Example
Output:
Thread-1 finished executing Thread-2 finished executing child thread destroyed Parent thread destroyed
Related Posts
Subscribe to Tpoint Tech
We request you to subscribe our newsletter for upcoming updates.