import java.io.*;
//javac test_run.java
public class test_run extends Thread{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("-->Welcome to thread building<--");
System.out.print("type name as worker : ");
String str = br.readLine();
thread_this pt = new thread_this(str);
pt.process_this("worker");
}
}
class thread_this extends Thread
{
public thread_this(String str )
{
System.out.println("string Constructor");}

public void process_this(String str)
{
Thread th = new thread_this(str) ;
th.setName(str);
th.start();
System.out.println("Hello from "+ th.getName()+ " thread!" + " id " + th.getId());
System.out.println("Hello from "+ Thread.currentThread().getName()+ " thread!" + "id " + Thread.currentThread().getId());
}
public void run() {
System.out.println("Hello from a thread!");
}

}

with Eclipse software


import java.io.*;
public class test extends Thread{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("-->Welcome to thread building<--");
System.out.print("type name as worker : ");
String str = br.readLine();
thread_this pt = new thread_this(str);
pt.process_this("worker");
}
}
class thread_this extends Thread
{
public thread_this(String str )
{
System.out.println("string Constructor");}

public void process_this(String str)
{
Thread th = new thread_this(str) ;
th.setName(str);
th.start();
System.out.println("Hello from "+ th.getName()+ " thread!" + " id " + th.getId());
System.out.println("Hello from "+ Thread.currentThread().getName()+ " thread!" + "id " + Thread.currentThread().getId());
}
public void run() {
System.out.println("Hello from a thread!");
}

}