Pre-Proposal: Linguistic support for locks

Reinier Zwitserloot reinier at zwitserloot.com
Mon Mar 9 03:05:37 PDT 2009


Ditto - try is the wrong keyword for this one. protected works great.  
Also gets rid of the 'you can add catch / finally blocks at the end  
for consistency' device, which really doesn't make too much sense for  
locks.

  --Reinier Zwitserloot
Like it? Tip it!
http://tipit.to



On Mar 9, 2009, at 00:56, Jesse Wilson wrote:

> On Sun, Mar 8, 2009 at 11:20 AM, Joshua Bloch <jjb at google.com> wrote:
>
>>   try (<lock-expr>) {
>>       <code>
>>   }
>
>
> try is definitely the wrong keyword here. Mostly because there's  
> already a
> method Lock.tryLock() that is not at all related to this sweet sugar.
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/Lock.html#tryLock()
>
>  1. Use the protected keyword in place of try.
>>
>
> This is fantastic. I especially like that proper Locks would become  
> just as
> easy-to-use as the built-in monitor on Object.
>




More information about the coin-dev mailing list