[concurrency-interest]PoolExecutor & Lock

Sumeet Parmar sparmar@necam.com
Thu, 21 Feb 2002 10:17:22 -0600


>
>
>I REALY prefere symetric names for lock (like lock/unlock/tyrlock or may
>be others), but acquire/release is not my favorite. this names remember
>me to those windows api fucntions like waitforsingleobject... of course
>it's just a matter of taste, but would be cleaner (at least for me:-)
>
My thoughts are same. Windows API forces many such complimentary 
before-after
functions. While on the other hand I'm not sure if there's a way around 
it unless the language
spec is changed for Lock like objects to be made aware of scope i.e. the 
enclosing braces.

my two paisas,
-Sumeet

>
>
>another thing for lock: it'd be usefule if I can mix the "old sytle"
>synchronize and the new acquire. what I mean the lock can be the monitor
>on the lock itself. eg:
>-----------
>Lock l =...
>try
>{
>  l.lock();
>  try
>  {
>    ....
>  }
>  finally 
>  { 
>    l.unlock();
>  }
>}
>catch (InterruptedException e)
>{
>  ...
>}
>-----------
>would be the same as:
>-----------
>Lock l =...
>synchroznied(l)
>{
>...
>}
>-----------
>this means when the synchronization appear in a block than I can do
>the safer and much cleaner code. actually I don't know (since I don't 
>think about it) whether it's possible or not, but the current lock
>semantics are make the code less readable. it'd be useful even if we
>have to change/extend jvm or lang spec
>
>one more thing about it, for ReadWriteLock it'd be also useful if the 
>write lock would be equal to the ReadWriteLock's object lock, ie.:
>-----------
>ReadWriteLock rw =...
>Lock l = rw.getWriteLock();
>try
>{
>  l.lock();
>  try
>  {
>    ....
>  }
>  finally 
>  { 
>    l.unlock();
>  }
>}
>catch (InterruptedException e)
>{
>  ...
>}
>-----------
>would be equal something like:
>-----------
>ReadWriteLock rw =...
>synchroznied(rw)
>{
>}
>-----------
>this style is cleaner, natural and in this case this api realy fit into 
>the current java spec. IMHO.
>yours.
>