[CODE=java]import java.util.Scanner; class Sum { private int value; public int get() { return value; } public void set(int sum) { this.value = sum; } } class Summation extends Thread { private int upper; private int lower; private Sum sumValue; public Summation(int upper, Sum sumValue) { if (upper < 0) throw new IllegalArgumentException(); this.upper = upper; this.sumValue = sumValue; } public void run() { int sum = 0; for (int i = 1; i >= lower && i <= upper; i++) sum += i; System.out.println(this.getName() + " is done"); sumValue.set(sum); System.out.println(this.getName() + " " + sum); } } public class MultithreadSum …

Member Avatar
+0 forum 0

The End.