Code to print even and Odd number using two threads
If the only requirement is to have two threads, one printing even numbers and other printing odd numbers, then your solution is unnecessarily complicated. The fact that you share the same data model for both threads forces you to synchronize access to the object making the solution unnecessarily complicated. The assignment did not require numbers being printed in sequence, so the coordination between the threads is unnecessary.

public class Counter implements Runnable {
    private final int start;
    private final int end;
    private final int increment;
    ... add boilerplate constructor ...
    public void run() {
        for (int i = start; i &lt;= end; i += increment) {
            System.out.println(i);
        }
    }
}


Start threads:

new Thread(new Counter(1, 10, 2)).start();
new Thread(new Counter(2, 10, 2)).start();