From: Alex Twisleton-Wykeham-F. <al...@fi...> - 2006-03-13 13:27:33
|
On Mon 13 March 2006 12:34, Endre St=F8lsvik wrote: > On Sun, 12 Mar 2006, Alex Twisleton-Wykeham-Fiennes wrote: > | All, > | > | more performance tweaks, this one to the org.webmacro.engine.Variable > | class. > > Excellent performance tuneup you're into, Alex! > > | - made the getVariableName() method check to see if _vname has been > | initialised, and if not then build the name before returning it. This = is > | now synchronized as it changes the state of the object. > > So? If you don't synchronize then you could potentially have two threads modify= ing=20 the state of the Object simultaneously. In this situation it is not the en= d=20 of the world, because the generation of the result is a) not that expensive= ,=20 and b) not dependent on other mutable properties, but I find it best to app= ly=20 thread-safe approaches to everything that changes state and then remove the= m=20 if profiling shows it to be a problem. Much better to start safe and then= =20 remove redundant safety when required than to start unsafe and try and make= =20 things safe when a weird multi-threading bug occurs... > Is it shared across threads? I'd have to double check this one. It's a bit of a twisty turny passage of= =20 Macro inheritance and it isn't necessarily obvious... Alex ps synchronizing is really not the overhead that it used to be in older JVM= s=20 and it *really* makes your life easier to not have any multi-threading=20 bugs... |