import java.lang.*;
import java.io.*;
class MatMulti extends Thread
{
static int arr1[][];
static int arr2[][];
static int arr3[][];
static int a=2;
int row;
MatMulti(int i)
{
row=i;
this.start();
}
public void run()
{
int i,j;
for(i=0;i<a;i++)
{
arr3[row][i]=0;
for(j=0;j<a;j++)
arr3[row][i]=arr3[row][i]+arr1[row][j]*arr2[j][i];
}
}
public static void main(String args[])
{
int i,j;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the order of Matrix : ");
try
{
a=Integer.parseInt(br.readLine());
}catch(Exception e){}
arr1=new int[a][a];
arr2=new int[a][a];
arr3=new int[a][a];
System.out.println("Enter the First Matrix : ");
for(i=0;i<a;i++)
{
for(j=0;j<a;j++)
{
try
{
arr1[i][j]=Integer.parseInt(br.readLine());
}catch(Exception e){}
}
}
System.out.println("Enter the Second Matrix : ");
for(i=0;i<a;i++)
{
for(j=0;j<a;j++)
{
try
{
arr2[i][j]=Integer.parseInt(br.readLine());
}catch(Exception e){}
}
}
MatMulti mat[]=new MatMulti[a];
for(i=0;i<a;i++)
mat[i]=new MatMulti(i);
try
{
for(i=0;i<a;i++)
mat[i].join();
}catch(Exception e){}
System.out.println("OUTPUT :");
for(i=0;i<a;i++)
for(j=0;j<a;j++)
System.out.println(arr3[i][j]);
}
}
Thursday
//
Labels:
JAVA PROJECTS
//
2
comments
//
2 comments to "MULTITHREADED MATRIX MULTIPLICATION IN JAVA"
Powered by Blogger.
Blog Archive
-
▼
2011
(50)
-
▼
August
(12)
- INTRODUCTION TO JAVA
- ABSTRACTION
- INHERITANCE
- ENCAPSULATION
- SIMPLE JAVA PROGRAM
- BABYLONIAN METHOD FOR DETERMINING A SQUARE ROO...
- TRIGONOMETRIC FUNCTIONS CALCULATED USING MCLAUREN ...
- PROJECT ON RESERVATION
- CALCULATOR USING JAVA
- MANAGEMENT OF SCHOOL RECORDS USING JAVA
- MULTITHREADED MATRIX MULTIPLICATION IN JAVA
- PROJECT ON LIBRARY SYSTEM IN JAVA
-
▼
August
(12)
Mike says:
Can you post an output example for this program?
Anonymous says:
CAN YOU EXPLAIN EACH LINE IN THIS CODE IN DETAILS??