Done With Venkat S’s Book

I am finally all through Programming Concurrency on the JVM by Venkat Subramaniam.

I am looking at some code he wrote to test classes in the java.util.concurrent.lock package. I might go through that.

I have a feeling that a lot of what I went through might be obsolete soon. There was a lot of code that could be done more concisely with lambdas, which are coming soon in Java 8. I think you might be able to do extend the ReadWriteLock class and have it take some code that you want to make thread-safe. In one of the times I saw him, he said that locks take care of any issues you would have with the synchronized keyword.

The problem is that you really need to use try/catch/finally blocks, and you should use the tryLock() method, and use a timeout. It can be a lot of code.  You might want to change one variable, but instead of having one line in your setter, you might need about 6. But if you could send that one line to a LockLambda (or whatever you want to call it), it would be better. You might need two, which granted is still more than one, but the LockLambda could handle all the try/catch/finally/get the lock/set the timeout/release the lock work for you, and you might be able to re-use the same LockLambda class.

I might blog about Akka, although I am not too thrilled with it. I do not like Scala, and some of the Akka APIs call Scala APIs. I liked GPars better. Although there were some things in GPars that are not worth the effort to use in Java, you can pretty much use just the GPars APIs. You do not need to look at any Groovy if you do not want to. I think some things I did not like with Akka will be easier once lambdas come out. But I still do not like Scala.

I may still look at the Play Framework.


Image from an 11th century manuscript made at the Abbey Library of Saint Gall  (Wikipedia page here), image from e-Codices, assumed allowed under Fair Use.