Java program for getName(), getId() and getPriority() methods
KW.java
class KW { public static void main(String[] args) { Thread t1=Thread.currentThread(); System.out.println("Thread Name "+t1.getName()); System.out.println("Thread Priority "+t1.getPriority()); t1.setName("My Thread"); System.out.println("Name "+t1); } }
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW Thread Name main Thread Priority 5 Name Thread[My Thread,5,main] kodingwindow@kw:~$
Comments and Reactions
What Next?
Java program for join() and sleep() methods
Java program for priority thread
Java program for a daemon thread
Advertisement