小编use*_*217的帖子

通知不起作用.. waitng永远线程Java

您好我是编程的新手,我正在尝试做一个简单的生产者 - 消费者问题..但不幸的是我的线程永远等待..notify不工作..任何想法?:/

public synchronized void order() throws Exception{

    System.out.println("User "+name+" requests:\n"+"cherries=" + cherries);

    while(checkValues()==true){
        System.out.println(name+"  waiting");
        wait(); 
    } 
    notify();
    Update();
    store.toString();

    System.out.println(name+" gets resources ");
    Thread.sleep(5000);
 }
Run Code Online (Sandbox Code Playgroud)

java multithreading notify wait forever

1
推荐指数
1
解决办法
68
查看次数

标签 统计

forever ×1

java ×1

multithreading ×1

notify ×1

wait ×1