Wednesday, May 4, 2016

Create Thread For Every Character Of String



import java.util.Scanner;

public class CharThrd extends Thread
{
public static void main(String[] args)
       {

System.out.println(Thread.currentThread().getName());
Scanner scn=new Scanner(System.in);
System.out.println(" type name");
String s=scn.nextLine();
for(int i=0;i<s.length();i++)
                 {
new Thread(""+s.charAt(i))
                      {
public void run()
                         {
System.out.println("Thread : "+getName()+" Running ");
}
}.start();
}
}

}