title: Why they show 1 times for the answer but already create 2 threads
body: <p>I want the threads to show odd and even number and I've already created 2 threads but when I run it, it shows only 1 thread.</p>
  <p>My question is how I can call the even and odd number using threads?</p>
  <p>This is a sample output when I'm running my code. I need the number odd and even between 0 and 9.</p>
  <pre><code>Please input x:
  0
  Please input y:
  9
  Even 0
  
  this is my code for calling threads
  
  public class MyRunnable {
  
         public static void main(String[] args) {
  
             Scanner in = new Scanner(System.in);
             System.out.println(&quot;Please input x:&quot;);
             int x= in.nextInt();
             System.out.println(&quot;Please input y:&quot;);
             int y=in.nextInt();
  
             TaskEvenOdd  oddRunnable=new TaskEvenOdd (1,x,y);
             TaskEvenOdd  evenRunnable=new TaskEvenOdd (0,x,y);
  
             Thread t1=new Thread(oddRunnable,&quot;Odd&quot;);
             Thread t2=new Thread(evenRunnable,&quot;Even&quot;);
  
             t1.start();
             t2.start();
  
         }
     }
  
  
  package com.company;
  //import java.util.Scanner;
  
  public class TaskEvenOdd implements Runnable {
     private final int remainder;
     private int x;
     private final int y;
     static final Object lock=new Object();
  
  
     // standard constructors
    public TaskEvenOdd (int remainder,int x, int y){
         this.remainder = remainder;
         this.x = x;
         this.y = y;
     }
  
  
     @Override
     public void run() {
         while (x&lt; y) {
             synchronized (lock) {
                 while (x % 2 != remainder) { // wait for numbers other than remainder
                     try {
                         lock.wait();
                     } catch (InterruptedException e) {
                         e.printStackTrace();
                     }
                 }
                 System.out.println(Thread.currentThread().getName() + &quot; &quot; + x);
                x++;
                 lock.notifyAll();
             }
         }
     }
  }
  </code></pre>