在线程中关于notify使用碰到的问题

问题遇到的现象和发生背景

在写多线程的时候使用notify发送的错误

问题相关代码,请勿粘贴截图
public class CommunicationTest {
    public static void main(String[] args) {
        Nummber nummber = new Nummber();
        Thread t1 = new Thread(nummber);
        Thread t2 = new Thread(nummber);
        t1.setName("线程1");
        t2.setName("线程2");
        t1.start();
        t2.start();
    }
}

class Nummber implements Runnable{
    private int nummber = 1;
    @Override
    public void run() {
        while (true)
        {
            synchronized (Nummber.class) {
                notify();
                if (nummber <= 100)
                {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() +":"+ nummber);
                    nummber++;
                    try {
                        //使得调用如下方法的线程进入阻塞状态
                        wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                else{
                    break;
                }
            }
        }
    }
}


运行结果及报错内容

Exception in thread "线程2" Exception in thread "线程1" java.lang.IllegalMonitorStateException
at java.lang.Object.notify(Native Method)
at correspondence.Nummber.run(CommunicationTest.java:26)
at java.lang.Thread.run(Thread.java:748)
java.lang.IllegalMonitorStateException
at java.lang.Object.notify(Native Method)
at correspondence.Nummber.run(CommunicationTest.java:26)
at java.lang.Thread.run(Thread.java:748)

我的解答思路和尝试过的方法

将synchronized里面的参数改为this就能运行

我想要达到的结果

我想知道这是什么原因造成的,当同步监视器里面的参数是当前类的时候,会出现非法监视这个问题,改为this就能执行

解锁和加锁要为用一个对象, 代码中持有的锁是Nummber.class 对象锁, 解锁应也要Nummber.class 对象解锁, 而代码中是用this的notify解锁。