There's more...

The Thread class includes other methods that provide information about it that can be useful. These methods are as follows:

  • activeCount(): This method returns the number of active threads in a group of threads.
  • dumpStack(): This method prints the stack trace of a thread to the standard error output.

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.