COMP 402: Production Programming← Concurrency → |
Home — Spring 2012 | | | Information | | | Resources | | | DrJava | | | SourceForge | | | Blog |
ArrayList _buffer=new ArrayList();
instead of
ArrayList _buffer=new ArrayList();
.
That way, _buffer
can only contain elements of type T
.
But this is not related to concurrency. In DrJava, however, we don't want to use "raw"
types, i.e. classes where you could specify a type. For all Java
collections (ArrayList, LinkedList, HashSet, HashMap, etc.), for
example, we want to specify the types they contain.The other solutions were similar. What differed was the use of an
array instead of a list (there are no generic arrays), the use of
notify()
instead of notifyAll()
, and item 2
above.
waitingReaders--;
and waitingWriters--;
are not in the proper place; they may be executed even when the matching waitingWriters++;
and waitingReaders++;
are not executed.There are other ways to implement the homework, but here are our solutions:
URL: http://www.cs.rice.edu/~javaplt/402/12-spring/lectures/conc3/index.shtml