0% found this document useful (0 votes)
25 views

pl-java-practical-11-with-output

The document contains a Java program that demonstrates multi-threading by defining three classes that extend the Thread class. Each thread prints a series of messages in a loop, and the main method starts all three threads. The output shows interleaved execution of the threads, illustrating concurrent processing.

Uploaded by

grojamani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

pl-java-practical-11-with-output

The document contains a Java program that demonstrates multi-threading by defining three classes that extend the Thread class. Each thread prints a series of messages in a loop, and the main method starts all three threads. The output shows interleaved execution of the threads, illustrating concurrent processing.

Uploaded by

grojamani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// multi threading practical 11

class one extends Thread


{
public void run()
{
for(int i=1;i<=5;i++)
{
System.out.println("OOPS ->i=" +i);
}
}
}
class two extends Thread
{
public void run()
{

for(int j=1;j<=5;j++)
{
System.out.println("THROUGH->j="+j);
}
}
}
class three extends Thread
{
public void run()
{
for(int k=1;k<=5;k++)
{
System.out.println("java->k="+k);
}
}
}
class thread
{
public static void main(String args[])
{
one ob1=new one();
two ob2=new two();
three ob3 =new three();
ob1.start();
ob2.start();
ob3.start();
}
}

output:
D:\deepakcs2>java thread
OOPS ->i=1
OOPS ->i=2
OOPS ->i=3
OOPS ->i=4
OOPS ->i=5
java->k=1
THROUGH->j=1
THROUGH->j=2
THROUGH->j=3
java->k=2
THROUGH->j=4
THROUGH->j=5
java->k=3
java->k=4
java->k=5

D:\deepakcs2>java thread
OOPS ->i=1
OOPS ->i=2
java->k=1
java->k=2
java->k=3
java->k=4
THROUGH->j=1
java->k=5
OOPS ->i=3
THROUGH->j=2
OOPS ->i=4
THROUGH->j=3
OOPS ->i=5
THROUGH->j=4
THROUGH->j=5

You might also like