News for hackers. Stuff that matters.
Re:A bad citizen in Javaland (2006) by pbh101 on Thursday December 03, 2015 @02:31PM (#10671920)
Especially in the multi-core era, this becomes more and more important. Thanks to the Java Memory Model specification, if you are using constructors (and yes, pretty much every DI framework by now has this feature), with just a bit of care[1] you can ensure that your object is never visible to any threads without it having been completely constructed.

[1] Make sure to not leak references to your object in your constructor. Most of the time that you would want to do this is starting a service or registering a handler, etc. The solution is to use a static creation method which first calls the constructor, and then registers/subscribes it, etc.

There are no comments on this comment yet.