The program to creates and run the following three threads. The first thread prints the letter ‘a’ 100 times. The second thread prints the letter ‘b’ 100 times. The third thread prints the integer 1 to 100.
Code:
Output:
Code:
class A extends Thread
{
public void run()
{
for(int i=0; i<100; i++)
{
System.out.print("a\t");
}
}
}
class B extends Thread
{
public void run()
{
for(int i=0; i<100; i++)
{
System.out.print("b\t");
}
}
}
class C extends Thread
{
public void run()
{
for(int i=0; i<100; i++)
{
System.out.print((i+1)+"\t");
}
}
}
class S8P1_Thread
{
public static void main(String args[])
{
new A().start();
new B().start();
new C().start();
}
}
Output:
No comments:
Post a Comment