本帖最后由 zychere 于 2014-07-17 14:20:15 编辑

解决方案 »

  1.   

    不能指定唤醒 因为没有api 
    至于随机唤醒是否有规则 不了解jvm源码 不清楚
      

  2.   

    不能指定唤醒某个线程,因为这是jvm自己调度的。猜测一下一楼说的意思:所有在同一个锁对象上调用wait的线程中,如果有优先级高的,那么他将被优先唤醒。是吧?这个我还真没有试验过,不得而知,一楼试验过吗?
      

  3.   

    notify()不能唤醒指定的单一线程,只能用notifyAll()唤醒全部线程,要唤醒单一线程,可以看看 java.util.concurrent.locks ,这个可以实现
      

  4.   

    如果你想制定某一类线程优先运行,可以考虑优先级。notifyAll()没有办法指定线程获取资源!
      

  5.   

    Java API描述如下:
    Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods. 不能指定,唤醒是随意的