Threads

2 comments - Post a comment

/* Implementation Of Threads */

import java.io.*;
import java.util.*;

class AA extends Thread
{
int i;
public void run()
{
System.out.println("Thread A");
for(i=0;i<5;i++)
{
System.out.println("Thread A : "+i);
yield();
}
}
}
class B extends Thread
{
int i;
public void run()
{
System.out.println("Thread B");
for(i=0;i<5;i++)
{
System.out.println("Thread B : "+i);
yield();
}
}

}
class C extends Thread
{
int i;
public void run()
{
System.out.println("Thread C");
for(i=0;i<5;i++)
{
System.out.println("Thread C : "+i);
yield();
}
}
}
class ThreadLionel
{
public static void main(String []args)
{
AA a = new AA();
B b = new B();
C c = new C();
a.start();
b.start();
c.start();
}
}
/*
--------------------OUTPUT--------------------
Thread A
Thread A : 0
Thread A : 1
Thread B
Thread B : 0
Thread C
Thread C : 0
Thread A : 2
Thread B : 1
Thread C : 1
Thread A : 3
Thread B : 2
Thread C : 2
Thread A : 4
Thread B : 3
Thread C : 3
Thread B : 4
Thread C : 4
*/

 
This Post has 2 Comments Add your own!
Anonymous - January 17, 2011 at 4:14 AM

16529.....83490

Anonymous - February 2, 2011 at 5:12 AM

96763.....72831

Post a Comment