[quote]I wish synchronized was extended with a nanosecond timeout and could throw a RuntimeException if it didnt get a lock in time 
Cas 
[/quote]
This is what I mean about it being nice and simple but at the cost of a lot of power.
I see where you’re coming from on that, and I would definitely move a JDC vote to an RFE for this post-structs :).
But it would be quite a complex change. You’d either have to add an extra code-block to the syntax, as well as the extra args, or else add some new API to the core libraries - and ask for developers to update all legacy code that depends upon code-analysis of the existence/location of the synchronized keyword. (I would guess, going on past examples, that the latter would be enough to cause Sun to refuse it - they seem particularly keen not to upset large users of java with big chunks of legacy code by adding non-forwards-compatible changes).
In fact, I can’t see how you could do it sensibly with an API, since java doesn’t support closures etc, so you can’t embed “the code I want you to run” into a variable to pass to the API; you’d have to do a Runnable-esque approach which IMHO is prohibitively ugly, and only works at a class level.
So…it would need to be a syntax change, something like:
public void something()
{
synchronized( this )
{
//...do something
}
timeout( 10000 )
{
System.out.println( "I waited 10000 nanoseconds but couldn't get the lock" );
}
}
Nice to wish for, but I’d say there isn’t a snowball’s chance in hell we’d ever get it ;). Perhaps in whatever language comes next, after Java and C#? Looking at the timeline C - C++ - Java, we’re due for another leap forward sometime in the next 1-3 years ;D…although mayble it’ll be another skunkworks project most people don’t hear about for the first couple of years.