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

Note

note

Uploaded by

Zezo-elganzory
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Note

note

Uploaded by

Zezo-elganzory
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

package com.

company;

import java.util.*;
class parallelAssignment implements Runnable{
double[] x;
parallelAssignment(double[] x){
this.x=x;
}
@Override
public void run() {
Random rd = new Random(); // creating Random object
for (int i = 0; i < this.x.length; i++) {
x[i] = rd.nextInt(100);
System.out.println(x[i]);
}
}
}
class sum implements Runnable{
double[] x;
sum(double[] x){
this.x=x;
}
@Override
public void run() {

double sum=0;
for (int i=0; i<this.x.length ; i++) {
sum = sum + x[i];
}
System.out.print("Sum is"+" "+sum);
}
}
class sort implements Runnable{
@Override
public void run() {

}
}
class min implements Runnable{
@Override
public void run() {

}
}
class max implements Runnable{
@Override
public void run() {

}
}
public class Main {

public static void main(String[] args) {


double arr[] = new double[10];

sum a = new sum(arr);


parallelAssignment r = new parallelAssignment(arr);
Thread t1 = new Thread(r);
Thread t2 = new Thread(a);
synchronized (t1){
t1.start();
t2.start();
}

You might also like