How it works...

In this recipe, you have used the following methods to get information about a Thread class:

  • getId(): This method returns the ID of a thread. It's a unique long number and it can't be changed.
  • getName(): This method returns the name of a thread. If you don't establish the name of the thread, Java gives it a default name.
  • getPriority(): This method returns the priority of execution of a thread. Threads with higher priority are executed in preference to threads with lower priority. It's an int value that has a value between the MIN_PRIORITY and MAX_PRIORITY constants of the Thread class. By default, threads are created with the same priority that specified by the constant NORM_PRIORITY of the Thread class.
  • getState(): This ...

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.