Object.{wait,notify}() should support a new QUEUE/CONDITION parameter

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 1.2.2
    • Component/s: core-libs
    • x86
    • windows_95

      Name: mc57594 Date: 11/15/99


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)


      The wait() and notify() methods should have a new Condition parameter, so that,
      you can wait in different queues for different conditions. Example:

      class Consumer {
         ...
         if (num_elements == 0 )
               wait (production);

         <consume the element>

         --num_elements;
         notify (consumption)
         ...
      }

       


      class Producer {
         ...
         if (num_elements == MAX )
               wait (consumption);

         <produce the element>

         ++num_elements;
         notify (production)
         ...
      }



      The code is more clear, you avoid while loops and you avoid to wake up a process
      that doesn't have to be notified. This is the natural way that monitors are
      usually implemented.
      (Review ID: 97799)
      ======================================================================

            Assignee:
            Martin Buchholz
            Reporter:
            Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: