From the course: Java Threads
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Other useful methods of the Thread class - Java Tutorial
From the course: Java Threads
Other useful methods of the Thread class
- [Instructor] The Thread class has a few other instance and static methods that come in handy when you're creating multi-threaded applications. For example, you can invoke the getId method on a thread instance, which will return the unique identifier of that thread. The identifier will always be a positive long value. It's generated at the time of thread creation. When the thread is terminated, the ID could be reused by another thread. The getName instance method returns the name of the thread on which it's invoked. You know already that all threads are assigned a priority value. This value is assigned at the time of thread creation, and its value falls within the range of 1 to 10. 1 is the minimum priority, and 10 is the maximum priority. The priority of a thread can be retrieved using the getPriority instance method that returns an int value between 1 and 10. The getState instance method returns the status of the thread…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Pausing execution of a thread3m 52s
-
(Locked)
Interrupting a thread5m 42s
-
(Locked)
Implementing thread interruptions6m 13s
-
(Locked)
Making a thread to wait until another thread terminates5m 39s
-
(Locked)
Other useful methods of the Thread class2m 42s
-
(Locked)
Challenge: Webinar polling system1m 53s
-
(Locked)
Solution: Webinar polling system5m 9s
-
(Locked)
-