[concurrency-interest] Fwd: ReadWriteLocks and Conditions

Peter Veentjer alarmnummer at gmail.com
Wed Feb 7 03:45:06 EST 2007


Hi Tim,

I haven't found another synchronization stone that fitted my needs.
Can you point me to the work others have done? Something I want to
prevent is 'modifying' other synchronization structures so they behave
the way I want. Concurrency control is complex, and that is why I
prefer using synchronization structures that make clear what they are
doing.

I'm going to look at simplifying the design by using a semaphore.
Thank you for the suggestion.



On 2/6/07, Tim Peierls <tim at peierls.net> wrote:
> LendableReference is essentially a resource pool of size 1. Other folks have
> done a lot of work on the general case -- why not take advantage of that?
>
>  Or if you really want to roll your own, consider using Semaphores, as
> described in section 5.5.3 of Java Concurrency in Practice.
>
>  --tim
>
>
> On 2/6/07, Peter Veentjer <alarmnummer at gmail.com> wrote:
>
> > Example usage:
> >
> > while(true){
> >         Runnable task = lendableRef.take();
> >         try{
> >                 task.execute();
> >         }finally{
> >                 lendableRef.takeBack(task);
> >         }
> > }
> >
> > By placing a Runnable in the lendableRef, the task is being executed.
> > By removing the Runnable from the lendableRef (so setting a null
> > value) the take blocks.
> >
>


More information about the Concurrency-interest mailing list