I've been working on threads in Java, and this is my attempt at doing running 2 different threads to output the even numbers from 1-30, as well as the odd numbers from 1-30, each in a different thread. I am not sure if I've done something wrong or not, and I hope you can lend me some help.
public class evenThread implements Runnable{
public static void run(){
System.out.println("Even Numbers: ")
for(int j = 2; j <= 30; j + 2){
System.out.println(", " & j);
}
}
}
public class oddThread implements Runnable{
public static void run(){
System.out.println("Odd Numbers: ")
for(int i = 1; i <= 30; i + 2){
System.out.print(", " & i);
}
}
}
public static void main(String args[]){
evenThread t1 = new evenThread();
oddThread t2 = new oddThread();
t1.start();
t2.start();
}
}