Skip to main content

Merging two string array with the use of threads

import java.io.*;
import java.lang.*;

class M3 extends Thread
{
String c[]=new String[10],t;
int i,j;
M3(M1 a,M2 b)
     {
for(i=0;i<a.a.length;i++)
c[i]=a.a[i];
for(i=0;i<b.a.length;i++)
c[5+i]=b.a[i];
    }
public void run()
   {

for(i=0;i<9;i++)
{
for(j=0;j<8;j++)
{
if(c[j].compareTo(c[j+1])>0)
{
t=c[j];
c[j]=c[j+1];
c[j+1]=t;
}}}
System.out.println("\nThe full list");
for(i=0;i<10;i++)
 System.out.println(c[i]);
    }


}

class M1 extends Thread
{
int i;
String a[]=new String[5];

public void run()
{
try
{
DataInputStream dd= new DataInputStream(System.in);
System.out.println("Enter  for thread1");
for(i=0;i<5;i++)
for(i=0;i<5;i++)
{
a[i]=dd.readLine();

}
}
catch(Exception e) {}


}

}


class M2 extends Thread
{
int i;
String a[]=new String[5];

public void run()
{
try
{
DataInputStream dd= new DataInputStream(System.in);
System.out.println("Enter  for thread2");
for(i=0;i<5;i++)
{
a[i]=dd.readLine();
}
}
catch(Exception e) {}
}



}




public class Use2


{
public static void main(String args[])
{


M1 t1 = new M1();
M2 t2 = new M2();

t1.start();
try
{
t1.join();
}
catch(Exception e) {}

t2.start();

try
{
t2.join();

}
catch(Exception e) {}
M3 t3 = new M3(t1,t2);
t3.start();
}
}

Comments

Popular posts from this blog

PROGRAM TO PRINT COLOURS OF RAINBOW ACCORDING TO THE NO. INPUTTED BY THE USER

#include,stdio.h> #include<conio.h> void main() { int ch; printf("INPUT A NUMBER\n"); scanf("%d",&ch); switch(ch) { case 6: printf("Red"); break; case 5 : printf(" Orange"); break; case 4 : printf(" Yellow"); break; case 3 : printf(" Green"); break; case 2 : printf(" Blue"); break; case 1 : printf(" Indigo"); break; case 0 : printf(" Violet"); break; default : ("wrong input "); } } SIMPLE PROGRAMS FIND TYPE OF THE TRIANGLE TEMPERATURE CONVERSION COMMISSION OF A SALESMAN PRINT NUMBERS IN DESCENDING ORDER BIGGEST NUMBER AMONG THREE NUMBERS CALCULATE DIVISION A YEAR IS LEAP OR NOT A NUMBER IS ODD OR EVEN PRINT THE SQUARE ROOT ELSE PRINT N TO THE POWER 5 PRINT A NEW NUMBER BY ADDING 1 TO EACH DIGIT OF THE NUMBER PRINT THE NO. OF CURRENCY NOTES ACCORDING TO THE AMOUNT ENTERED DATA STRUCTURES ENTER DETAILS OF A STUDENT ENTER DETAILS OF A ST...

unix commands

 

Baby doge paws

Baby doge paws link 🎉 Join the BabyDoge PAWS Clicker adventure! Solve challenges, join daily events, and invite friends. Stay tuned for the token airdrop! 🐾 🌟 Earn 10k PAWS as a welcome bonus 🌟 Get 25k PAWS with Telegram Premium https://t.me/BabyDogePAWS_Bot?start=r_6394860582