Re: [ljc] Concurrency, multi-threaded programming: under the hood

From: Martijn V.
Sent on: Sunday, March 17, 2013 12:52 PM
+1 - Ben and I would also add that Java's Thread is like using assembly language for doing concurrency work on the JVM - try not to use it directly :-).

Heck, if you're really serious about using concurrent, thread-safe libraries and constructs you may actually want to look at languages on the JVM that *aren't* Java (which has mutability by default). The java.util.concurrent package combined with Brian's teachings is adequate (not even Brian and Doug Lea state they get it right all of the time), but no longer state of the art (Java 8 will bring some parity back). Looking at language/framework combinations such as Scala/Akka, Groovy/GPARs & Clojure will do you no harm, they tend to give you more inherit safety out of the box.

Also, several good points have been made on this thread about understanding your JVM, hardware and O/S - as mentioned, throwing 100 threads at a dual core CPU isn't going to help. I'll be talking about this again at Devoxx UK ("Java and the Machine"), and there are several other concurrency talks on as well, I'd recommend getting along to them.


On 17 March[masked]:58, Jack Shirazi <[address removed]> wrote:
Concurrency is hard. When I interview people, I am one of those who ask about concurrency. Usually I'm asking about how you diagnose concurrency issues, rather than how you code anything - because you can give all sorts of answers about concurrency coding whatever your level of experience, whereas you have to have a certain minimum level of understanding to explain how to diagnose issues.

The primary way to code concurrently and minimize concurrency bugs is to avoid explcitly writing concurrency code. This is my understanding from my concurrency guru - Brian Goetz. Basically, Brian's advice is that if you find yourself starting to write explicit concurrency handling, stop and look for a library class that does what you want, because concurrency bugs are subtle, non-obvious, and often difficult to reproduce, and the library class is likely to have had to handle most of them and been debugged by a community. The other things he's suggested, immutable objects, non-shared objects, etc, those are all workarounds when you can't find a library to do what you want.

The whole lambda addition in Java 8 is exactly along this line - if you use lambdas the code is concurrently executable by the libraries without you having to explicitly do any explicit concurrent handling (which is one of the reasons Brian is spearheading the project, it's close to his heart). Of course you have to be careful to avoid inadvertent concurrent data sharing or face the consequent race conditions, but you can't have everything.

Advice to students would be to read whatever Brian has written that's out there.

On 16/03/[masked]:36, Barry Cranford wrote:
Hi all,

We are often tasked to find Java developers with an understanding of low level core Java. Not necessarily specialist contractors at 5-600 pday, but permanent developers, one may classify as mid-senior level (40-60k). When pushed this is often defined by developers that understand what is going on 'under the hood' e.g. not just how to use popular frameworks but those that understand the concepts and principles beneath them. Whilst some companies will be a little more easy on practical experience, they will push for an understanding. 

Many developers don't make it through interview processes with feedback coming up time and again around a lack of understanding of multi threaded programming and concurrency. I have seen a few conversations recently on the list around these areas so I'm keen to understand the thoughts of the community on this. 

A few things I'm curious about...

- If we could put on some deep dive talks what subjects would you personally most like to have covered?
- Why are some developers drawn to this deeper level and why do some people seem to grasp these concepts so easily against others? 
- If you could offer advice to students starting out in Java development today, how would you suggest learning the fundamentals of these concepts? (reading, self study, projects, talks, oss, something else)?
- Have you been through this learning process in the past and had a eureka moment? What happened for you personally.

Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jack Shirazi ([address removed]) from LJC - London Java Community.
To learn more about Jack Shirazi, visit his/her member profile

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference, in collaboration with the LJC 12/13 Jun 14

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • New Relic

    New Relic makes sense of billions of metrics a day in real time.

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy