I am attempting to add two numbers together using 3 concurrent thread objects in one class. I have implemented the runnable interface and used the run() method. The error I am receiving states that my "class is not abstract and does not override abstract method run() in runnable.
very basic when it comes to threads. any help greatly appreciated.
//import packages import java.util.*; //random thread class public class RandomThread implements Runnable { //integer and object variables Random rNum1 = new Random(); Random rNum2 = new Random(); int num1, num2; RandomThread() { //chose random first number Thread thNum1 = new Thread() { //run method from runnable interface public void run() { for (int i = 0; i <= 10; i++) { num1 = rNum1.nextInt(11); } } }; thNum1.start(); //chose random second number Thread thNum2 = new Thread() { //run method from runnable interface public void run() { for (int i = 0; i <= 10; i++) { num2 = rNum2.nextInt(11); } } }; thNum2.start(); //chose random second number Thread thSum = new Thread() { //run method from runnable interface public void run() { //sum of 2 random numbers int sum = num1 + num2; System.out.println("The sum of " + num1 + " +" + num2 + " =" + sum); } }; thSum.start(); } //main method public static void main(String[] arguement) { //instance of class RandomThread rt = new RandomThread(); } }