#include <stdio.h>
#include<stdlib.h>
#include<pthread.h>
#define ROW 2
#define COL 2

int mat1[ROW][COL]={{2,3},{4,5}};
int mat2[ROW][COL]={{6,7},{9,3}};
int result[ROW][COL];

typedef struct{
  int row;
  int col;
}thread_data;

void* multiply (void* arg)
{     
    thread_data *data= (thread_data*)arg;
    int row= data->row;
    int col=data->col;
      int sum=0;
      for(int k=0;k<COL;k++)
          {
              sum+=mat1[row][k]*mat2[k][col];
          }
    int *p= (int*)malloc(sizeof(int));
    *p=sum;
    pthread_exit(p);
}

int main()
{
    pthread_t threads[ROW][COL];
    thread_data td[ROW][COL];
    int *status;
    for(int i=0;i<ROW;i++)
        {
            for(int j=0;j<COL;j++)
                {
                    td[i][j].row=i;
                    td[i][j].col=j;
                    pthread_create(&threads[i][j],NULL,multiply,(void *)&td[i][j]);
                }
        }
    for(int i=0;i<ROW;i++)
        {
            for(int j=0;j<COL;j++)
                {
                    pthread_join(threads[i][j],(void **)& status);
                    result[i][j]=*status;
                    free(status);
                }
         }
    for(int i=0;i<ROW;i++)
        {
            for(int j=0;j<COL;j++)
                {
                    printf("%d ",result[i][j]);
                }
            printf("\n");
        }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: