You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/09/14 03:27:59 UTC

DO NOT REPLY [Bug 23159] New: - [collections][PATCH] makes code easier to understand

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23159>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23159

[collections][PATCH] makes code easier to understand

           Summary: [collections][PATCH] makes code easier to understand
           Product: Commons
           Version: Nightly Builds
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Collections
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: janekdb@yahoo.co.uk


The attached patch makes the use of the monitor in BlockingBuffer easier to
understand by making the target of wait() and notifyAll() explicit.

The constructor in BlockingBuffer ensures that (lock == this) is always true.

In fact if it were ever true that (lock != this), then get() and remove() would
throw IllegalMonitorExceptions when this.wait() was invoked unless some other
thread already held the lock on this.

The patch also changes notify() in add() to notifyAll() because the object state
after a call to add() may be identical to the state after a call to addAll() and
it doesn't make immediate sense (to me) to wake up a potentially different set
of waiting threads depending on which method was invoked.