Thread yeild

import java.util.*;
import java.io.*;
//javac test_yeild.java
public class test_yeild {
public static int n1 = 1;
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();
String s = str + " : "+ n1++;
s = str + " : "+ n1++;
thread_this_yeild t_this = new thread_this_yeild(s);
t_this.process_this();
s = str + " : "+ n1++;
thread_that_yeild t_that = new thread_that_yeild(s);
t_that.process_that();
}
}
class thread_this_yeild extends Thread
{
public String str;
public thread_this_yeild(String str){ System.out.println("\tthis consturctor");
this.str = str;
}
public void process_this()
{
Thread th = new thread_this_yeild(str) ;
th.setName(str);
th.start();
System.out.println("Hello from this " + th.getName() + " id : " + th.getId());
}
public void run()
{
System.out.println(" --void this run--- " );
for (int i = 1; i <4 ; i++){
System.out.println("this run : " + i + " yield " + str);
//Thread.sleep(100);
Thread.yield();
System.out.println("this run : " + i + " work " + str);
}
}
}
//extends Thread
class thread_that_yeild implements Runnable
{
public String str;
public thread_that_yeild(String str)
{ System.out.println("\tthat consturctor");
this.str = str;
}
public void process_that()
{
Thread th = new Thread(new thread_that_yeild(str)) ;
th.setName(str);
th.start();
System.out.println("Hello from that " + th.getName() + " id : " + th.getId());
}
public void run()
{
System.out.println(" --void that run--- " );
for (int i = 1; i <4 ; i++){
System.out.println("that run : " + i + " yield " + str );
//Thread.sleep(100);
Thread.yield();
System.out.println("that run : " + i + " work " + str);
}
}
}