Most java developers don't know a thing about concurrency other than there is a synchronized keyword that can be applied and that does some magic. The pity is that it doesn't always does it's magic and little is understood why. As web developer, I admit that concurrency is a weak point. The only times I see it used is when self-implementing a cache what you shouldn't do anyway. For the rest, if you keep yourself to JavaEE standards as not using fields in session beans or servlets, you should be safe. (I think and hope!)
I happened to work on some swing code and work together with a swing developer, there concurrency is something that you have to know. The last book I read (
"Clean Code") also talked a bit about concurrency and then I started reading the
Sun tutorial.
I learned to use more of the provided framework instead of inventing the wheel yourself:
- Thread-safe collections such as ConcurrentHashMap. Very useful if you have some kind of cache instead of using synchronized all over the place and hope for the best.
- Use Executors and swingworkers instead of dealing with threads yourself.
Some other
concurreny tips from Joshua Bloch, Brian Goetz and others.
0 reacties:
Post a Comment