Proper use of wait and notify methods in java threading : I am new to java multithreading. I created simple producer-consumer pattern using wait and notify but my producer is getting called only once in tbe starting.

    class ProducerConsumerWorld{
    	public void producer() throws InterruptedException{
    		synchronized (this) {
    			while(true){
    				System.out.println("Producer thread started running");
    				wait();
    				System.out.println("Resumed Producing");
    			}
    		}
    	}
    	public void consumer() throws InterruptedException{
    		synchronized (this) {
    			while(true){
    				Thread.sleep(2000);
    				System.out.println("Consumer thread started running");
    				System.out.println("Press enter to consume all and start producing");
    				Scanner s = new Scanner(System.in);
    				s.nextLine();
    				notify();
    				Thread.sleep(2000);
    				System.out.println("consumed all");
    			}
    		}
    	}
    }

I am creating separate threads for producer and consumer. Producer thread only gets called in the starting and then after it is never getting executed. 