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 method returns the status of a thread. It's a Thread.State object. The Thread.State enumeration has all the possible states of a thread.
- getThreadGroup(): This method returns the ThreadGroup object of a thread. By default, threads belong to the same thread group, but you can establish a different one in the constructor of a thread.
- getStackTrace(): This method returns an array of StackTraceElement objects. Each of these objects represent a call to a method that begins with the run() method of a thread and includes all the methods that have been called until the actual execution point. When a new method is called, a new stack trace element is added to the array. When a method finishes its execution, its stack trace element is removed from the array.