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:~$
Advertisement