I ran into some (production!) code that looks like the snippet below:
synchronized(some_object) {
some_object = new some_object()
}
I would expect this to be subject to all sorts of horrible race conditions, and that a second thread Could possibly enter this block one the new object is created. My Java chops aren’t good enough to state definitively the expected behavior of above, so curious what you folks have to say before I refactor this.
As Francis says, this may not be a problem. Your snippet is equivalent to this: