4 Replies Latest reply on May 9, 2012 8:01 PM by Johnny_hunter

    how notifyAll change the threads state?

      hello all:

      I practice to write a simple BlockingQueue implementation using wait/notify, my add method looks like this:
      public synchronized void add(E element) throws InterruptedException{
                array[counter++] = element;
      Is the last line "notifyAll();" necessary? I think it changes the state of the waiting threads, if so, from what to what? Block to Runnable? or one of them from block to runnable while others from block to wait?

      If no such a line, what is happending to other threads? the current thread release the lock by exiting the method anyway.