Demonstration of Threads in java by capitalizing each character of each name

import java.lang.*;
import java.io.*;
class Threadx extends Thread
{
String nam;
Threadx(String t)
{
nam=t;
}
public void run()
{
int i,t,l;
l=nam.length();
char ch;

try
{
for(i=0;i<l;i++)
{
Thread.sleep(1000);
ch=nam.charAt(i);
t=ch;
if(t>=97&&t<=122)
t=t-32;
System.out.println((char)t);

}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
class Thready extends Thread
{
String nam;
Thready(String t)
{
nam=t;
}
public void run()
{
int i,t,l;
l=nam.length();
char ch;

try
{
for(i=0;i<l;i++)
{
Thread.sleep(100);
ch=nam.charAt(i);
t=ch;
if(t>=97&&t<=122)
t=t-32;
System.out.println("\t"+(char)t);

}
}
catch(Exception e)
{
System.out.println(e);
}
}
}



class Threadz extends Thread
{
String nam;
Threadz(String t)
{
nam=t;
}
public void run()
{
int i,t,l;
l=nam.length();
char ch;
try
{
for(i=0;i<l;i++)
{
Thread.sleep(2000);
ch=nam.charAt(i);
t=ch;
if(t>=97&&t<=122)
t=t-32;
System.out.println("\t"+"\t"+(char)t);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}



class aaa

{
public static void main(String args[])throws Exception
{
DataInputStream dd = new DataInputStream(System.in);

String s,s2,s3;
System.out.println("Enter 3 names");

s =dd.readLine();
s2=dd.readLine();
s3=dd.readLine();

Threadx ob=new  Threadx(s);
ob.start();

Thready ob2=new  Thready(s2);
ob2.start();
Threadz ob3=new  Threadz(s3);
ob3.start();

}
}

Post a Comment