Java program for getName(), getId() and getPriority() methods
Codeaft.java
class Codeaft
{
    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
codeaft@codeaft:~$ javac Codeaft.java
codeaft@codeaft:~$ java Codeaft Thread Name main Thread Priority 5 Name Thread[My Thread,5,main] codeaft@codeaft:~$
Comments and Reactions