Monday, August 30, 2010

Java concurrency is unsafe


Have you ever wondered how stuff in java.util.concurrent works?

I know I am late. It was in early 2000 (if not before that) when Doug Lea had published his Concurrent Programming in Java and had described what later became JSR 166 and then finally part of JDK 1.5 in 2004. Still better late than never.

I actually wanted to find out just a few things. I wondered how they provided the full semantic of happens-before as it works in volatile and synchronized but on the API level. I wondered if I would still find the volatile and synchronized and wait/notify buried down in the implementation details or would there be something else.

I did not look into the original Doug Lea's source code but I what I found in the latest JDK implementation made me smile.

They're using sun.misc.Unsafe to do the atomic changes and suspend enqueued threads (it's called parking). The sun.misc.Unsafe is native all over the place and, as you can tell from its name, is considered unsafe. It's not really Java per se.

Do you still think Java concurrency is safe? :)

Friday, August 27, 2010

Done. It's Mitchell.


It feels like I have waited for years and now I don't know why it took me so long.

I used to play guitar when I was in high school and I liked it a lot. I would spend all my free time months in a row just learning how to play and then practicing. I recall taking a series of lessons from a professional teacher when I was fourteen. And then we would gather together with my friends and play, and play, and play.

It then faded away. Job, family, kids - all that changed priorities and I don't remember at what point I left my guitar behind. I have to admit: I never had a good quality instrument that I would really feel connected to so that must have added to the equation too.

All in all, I didn't own a guitar for what feels like ten years. Though every time an acoustic track would play on a radio I would play along in my head if I knew how to or would try to imagine how I would do it.

It came down on me while I was on the road traveling for business. Last month I got to visit 12 different cities, spent 5 nights on a train, another 13 in different hotels, flew 10 segments, delivered close to 80 hours of training and seminar content. It was one kind of a trip... I can't tell at what point I decided that the first thing I will do when I am back will be buying a guitar - but I do remember having that thought so deep down I knew I will just do it.

And I did. First I spent some time online and just read about what's available. I knew there would be tons of choices so I wanted to lock down a price range. And then I went to a local guitar store to try out some and buy one.

When I explained what I was looking for they guy immediately gave me Mitchel MD100S as it was the only one with a solid top in my price range. I liked it a lot but I knew I had to compare it with others.

Fender DG 60 sounded a little deeper, seemed to have had better strings installed by default, but played noticeably harder.

Jasmine by Takamine was almost twice as cheap as the Mitchel but sounded very comparable (at least for my absolutely not professional ear). I might have considered buying this one if I haven't seen enough negative reviews on Amazon before. It played well, it sounded good, didn't feel as nice in hands but I would not really care if only I did not have an opinion about this particular one upfront.

And then I also played to Yamaha. The FG700S and a black color version of F335. 15 years ago I would die for a black color guitar :) But not this time. Both Yamaha sounded good and played well but were not as good looking as Mitchel.

First impression is hard to beat. Especially when it's a good one.

Done. It's Mitchel.