17.3 Thread Members and States
A thread has a whole set of states, such as a name and a priority, which can be queried and set. Not every property can be changed after startup so this section focuses on properties that can actually be changed.
17.3.1 The Name of a Thread
A thread has a large number of properties such as a state, a priority, and also a name. A name can be set with setName(...) and queried with getName() :
class java.lang. Threadimplements Runnable
-
Thread(String name)Creates a new Thread object and sets the name. Useful for subclasses that call the constructor via super(name) .
-
Thread(Runnable target, String name)Creates a new Thread object with a Runnable and sets the name.
-
final String getName()Returns ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access